auto-sync: 2026-05-02 21:33:03

This commit is contained in:
cfdaily
2026-05-02 21:33:03 +08:00
parent 15d791de6d
commit d546dba113
+8 -1
View File
@@ -79,7 +79,14 @@ def import_file(conn, filepath: Path) -> int:
# 类型转换(volume/amount可能是object
for col in ["volume", "turnover", "open_price", "high_price", "low_price", "close_price"]:
df[col] = pd.to_numeric(df[col], errors="coerce").fillna(0.0)
df[col] = pd.to_numeric(df[col], errors="coerce")
# 丢弃NaN行(价格/成交量为NaN说明原始数据异常)
na_before = len(df)
df = df.dropna(subset=["open_price", "close_price"])
if len(df) < na_before:
logger.warning("%s 丢弃 %d 条NaN行", filepath.name, na_before - len(df))
df["volume"] = df["volume"].fillna(0.0)
df["turnover"] = df["turnover"].fillna(0.0)
values = df[[
"symbol", "exchange", "datetime", "interval", "volume", "turnover",