diff --git a/data_platform/daily_all_update.py b/data_platform/daily_all_update.py index a9832a31..3646bfd8 100644 --- a/data_platform/daily_all_update.py +++ b/data_platform/daily_all_update.py @@ -142,8 +142,13 @@ def update_daily_parquet(code: str, new_data: pd.DataFrame) -> int: year = datetime.now().year parquet_path = DAILY_DIR / str(year) / f"{prefix}{clean}_daily.parquet" + # 确保date为字符串类型,避免和已有parquet的datetime.date冲突 + new_data = new_data.copy() + new_data["date"] = new_data["date"].astype(str) + if parquet_path.exists(): existing = pd.read_parquet(parquet_path) + existing["date"] = existing["date"].astype(str) combined = pd.concat([existing, new_data], ignore_index=True) combined = combined.drop_duplicates(subset=["date"], keep="last") combined = combined.sort_values("date").reset_index(drop=True)