SQL删除重复数据(根据多个字段),pandas的nan存入数据库报错
delete from M_FACTOR_DATA_TEST a where (a.factor_id,a.data_date,a.stock_code) in (select factor_id,data_date,stock_code from M_FACTOR_DATA_TEST group by factor_id,data_date,stock_code having count(*) > 1)
and rowid not in (select min(rowid) from M_FACTOR_DATA_TEST group by factor_id,data_date,stock_code having count(*)>1)
当pandas的nan存入数据库报错是,想法是把Nan替换为None
df = df.where(df.notna(), None)
where回遍历df中的每个元素,判断notna()时,用原本的元素填充(不变),遇到Nan时,用None替换