fix: drop NaN timestamps, use facecolor to suppress matplotlib warning

This commit is contained in:
张宗平
2026-06-11 22:17:27 +08:00
parent 404555ac0e
commit 817580ffe8
2 changed files with 11 additions and 2 deletions
+9
View File
@@ -41,6 +41,15 @@ def read_csv(path: str | Path, value_col: str = "value") -> tuple[list[int], lis
fixed = raw_strs.apply(_fix_hour60)
timestamps.loc[na_mask] = pd.to_datetime(fixed, errors="coerce")
# 丢弃时间戳仍为 NaN 的行(coerce 后无法恢复的异常时间戳)
valid_mask = timestamps.notna()
if not valid_mask.all():
n_drop = (~valid_mask).sum()
import logging
logging.getLogger(__name__).warning("dropping %d rows with invalid timestamps", n_drop)
timestamps = timestamps[valid_mask].reset_index(drop=True)
df = df[valid_mask].reset_index(drop=True)
timestamps_ms = (timestamps.astype("int64") // 10**6).tolist()
values = df[value_col].astype(float).tolist()