mssql 服务器数据库在 pandas iterrows odbc 驱动程序 ubuntu 机器中插入比预期更多的行
mssql server database inserting more rows than expected in pandas iterrows odbc driver ubuntu machine
print(f"df_shape {df.shape}")
(3497, 39)
但是,我看到超过 30,000 行被导入到数据库中。
for index, row in df.iterrows():
cursor.execute('INSERT INTO tbl_A(Sno,A,B) \
values(?,?,?,)', \
row.Sno, row.A, row.B)
cnxn.commit()
cursor.close()
类似的方法解决了这个问题,
df = df.loc[~df.index.duplicated()]
Pandas `groupby.aggregate` on `df.index.duplicated()`
duplicate removal Pandas concat: ValueError: Shape of passed values is blah, indices imply blah2
print(f"df_shape {df.shape}")
(3497, 39)
但是,我看到超过 30,000 行被导入到数据库中。
for index, row in df.iterrows():
cursor.execute('INSERT INTO tbl_A(Sno,A,B) \
values(?,?,?,)', \
row.Sno, row.A, row.B)
cnxn.commit()
cursor.close()
类似的方法解决了这个问题,
df = df.loc[~df.index.duplicated()]
Pandas `groupby.aggregate` on `df.index.duplicated()` duplicate removal Pandas concat: ValueError: Shape of passed values is blah, indices imply blah2