Compare commits

..
7 Commits
Author SHA1 Message Date
shellway 9697b59d4f fix:修复了财务类数据NAN值报错的bug。 2026-08-11 21:51:48 +08:00
xiaowu 4e7f599274 移除 equity 文件夹(误放:内容属于 gemdalepi 项目,gemdalepi 已有更新版) 2026-08-07 11:39:00 +08:00
shellway 1ad73d7a30 add readme 2026-08-06 14:23:05 +08:00
shellway fc33cc9ad7 add tool 2026-08-06 14:22:58 +08:00
shellway 18d8769e42 add tool 2026-08-06 14:22:57 +08:00
shellway a1de5e6332 add equity chart all 2026-08-06 14:22:57 +08:00
shellway 5e6c3fe10f add equity chart internal 2026-08-06 14:22:46 +08:00
+8 -2
View File
@@ -200,8 +200,14 @@ def batch_insert(table_name: str, df: pd.DataFrame, conn, conflict_columns: List
f"已保留最新公告记录 (去重后 {after_dedup} 行)" f"已保留最新公告记录 (去重后 {after_dedup} 行)"
) )
# pd.NaT / numpy NaN 等无法被 psycopg2 识别,统一替换为 Python None # pd.NaT / numpy NaN 等无法被 psycopg2 识别,统一替换为 Python None
df = df.where(pd.notna(df), None) # 关键:必须先 astype(object)pandas 的 datetime64 列无法存储 None
# 直接 where(..., None) 时 pandas 会把 None 自动提升回 NaT
# 导致 psycopg2 生成 'NaT'::timestamp 非法 SQL
# (典型报错: fina_indicator 的 ann_date 为空时报
# "invalid input syntax for type timestamp: \"NaT\"")。
# 转为 object 后 None 可正常存储,NaT/NaN 会被真正替换为 NULL。
df = df.astype(object).where(pd.notna(df), None)
rows = [tuple(row) for row in df.itertuples(index=False)] rows = [tuple(row) for row in df.itertuples(index=False)]