Spaces:
Sleeping
Sleeping
Upload updater.py
Browse files- updater.py +6 -0
updater.py
CHANGED
|
@@ -174,6 +174,12 @@ def process_one_file(local_file: Path, staging_root: Path):
|
|
| 174 |
"close": "Close", "volume": "Volume"
|
| 175 |
}, inplace=True)
|
| 176 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 177 |
combined_df = pd.concat([df, new_df], ignore_index=True)
|
| 178 |
combined_df = (
|
| 179 |
combined_df.drop_duplicates(subset=[date_col])
|
|
|
|
| 174 |
"close": "Close", "volume": "Volume"
|
| 175 |
}, inplace=True)
|
| 176 |
|
| 177 |
+
# Coerce data types so they match before concatenating
|
| 178 |
+
if pd.api.types.is_datetime64_any_dtype(df[date_col]):
|
| 179 |
+
new_df[date_col] = pd.to_datetime(new_df[date_col])
|
| 180 |
+
if getattr(df[date_col].dt, "tz", None) is not None:
|
| 181 |
+
new_df[date_col] = new_df[date_col].dt.tz_localize(df[date_col].dt.tz)
|
| 182 |
+
|
| 183 |
combined_df = pd.concat([df, new_df], ignore_index=True)
|
| 184 |
combined_df = (
|
| 185 |
combined_df.drop_duplicates(subset=[date_col])
|