@@ -170,13 +170,12 @@ def process_local_xrd_data(
170170
171171 df_echem = xrd_data ["Time_series_data" ]["data" ]
172172
173+ # Rename timestamp column to echem_timestamp
174+ # Note: Timestamp column is already standardized in process_echem_data()
175+ # Note: elapsed_time_seconds and elapsed_time_hours are already calculated in process_echem_data()
173176 df_echem ["Timestamp" ] = pd .to_datetime (df_echem ["Timestamp" ])
174177 df_echem = df_echem .rename (columns = {"Timestamp" : "echem_timestamp" })
175- time_deltas = df_echem .echem_timestamp - df_echem .echem_timestamp .iloc [0 ]
176- df_echem ["elapsed_time_hours" ] = [
177- delta .total_seconds () / 3600 for delta in time_deltas
178- ]
179- df_echem ["elapsed_time_seconds" ] = [delta .total_seconds () for delta in time_deltas ]
178+
180179 log_data .rename (columns = {"start_time" : "xrd_timestamp" }, inplace = True )
181180 log_data ["xrd_timestamp" ] = pd .to_datetime (log_data ["xrd_timestamp" ])
182181 df_merged = pd .merge_asof (
@@ -188,6 +187,7 @@ def process_local_xrd_data(
188187 )
189188
190189 # Adding scan_number to the echem data to be used for the lengend later.
190+ # Note: Timestamp column is already standardized to "Timestamp" in process_echem_data()
191191 echem_merged = pd .merge_asof (
192192 xrd_data ["Time_series_data" ]["data" ],
193193 xrd_data ["log data" ][["xrd_timestamp" , "scan_number" ]],
@@ -205,6 +205,11 @@ def process_local_xrd_data(
205205 "elapsed_time_seconds" : "time" ,
206206 }
207207 )
208+
209+ # Remove 'index' column if it exists in the data to avoid conflicts with pandas reset_index()
210+ if "index" in df_merged .columns :
211+ df_merged = df_merged .drop (columns = ["index" ])
212+
208213 xrd_data ["index_df" ] = df_merged
209214
210215 # Create a mapping from file_num to exp_num
0 commit comments