mirror of
https://github.com/Dasemu/skipredictor.git
synced 2026-11-26 07:16:15 +00:00
fix(data): normalize station history dates
This commit is contained in:
1 parent
2a34054399
commit
04eb0fde61
3 files changed
+115
-5
No files matched your search
@@ -84,8 +84,26 @@ def load_station_data(store: SQLiteStore) -> pd.DataFrame:
|
||||
else:
|
||||
logger.info("Loaded %d historical station rows from SQLite.", len(df))
|
||||
|
||||
# Parse dates with mixed formats (ISO and day-first variants)
|
||||
df["date"] = pd.to_datetime(df["date"], format="mixed", dayfirst=True)
|
||||
# Historical station data is stored in SQLite as ISO dates.
|
||||
if not pd.api.types.is_datetime64_any_dtype(df["date"]):
|
||||
df["date"] = pd.to_datetime(
|
||||
df["date"],
|
||||
format="%Y-%m-%d",
|
||||
errors="raise",
|
||||
)
|
||||
|
||||
# Keep station history aligned with the weather archive, which is fetched
|
||||
# only up to the last complete day.
|
||||
cutoff_ts = pd.Timestamp(date.today() - timedelta(days=1))
|
||||
original_len = len(df)
|
||||
df = df[df["date"] <= cutoff_ts].copy()
|
||||
dropped = original_len - len(df)
|
||||
if dropped > 0:
|
||||
logger.info(
|
||||
"Dropped %d station rows after %s while building the dataset.",
|
||||
dropped,
|
||||
cutoff_ts.date().isoformat(),
|
||||
)
|
||||
|
||||
# ---------- open_status ----------
|
||||
# idestado=1: open (normal operation)
|
||||
|
||||
Reference in new issue
Block a user