无类型对象没有属性“ tosql”

发布于 2025-01-19 14:42:21 字数 130 浏览 4 评论 0原文

df.to_sql('newcmc', con = engine, if_exists='append',index = False) 

运行上述代码时,它显示无类型对象没有属性“ to_sql”

df.to_sql('newcmc', con = engine, if_exists='append',index = False) 

While running the above code it is showing None type object has no attribute "to_sql"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心如狂蝶 2025-01-26 14:42:21

正如所有评论(正确地)所断言的那样。变量dfnone

特别是,它来自 df=df.to_excel("newcmc.xlsx",index=None),它给出了 None

这会起作用:


import pandas as pd

# example dataframe that is not None
d = {'a':[1,2,3]}
df = pd.DataFrame(d)

df.to_sql('newcmc', con = engine, if_exists='append',index = False) 

As all of the comments are (correctly) asserting. The variable df is none.

And in particular, this comes from df=df.to_excel("newcmc.xlsx",index=None) which is giving a None.

this would work:


import pandas as pd

# example dataframe that is not None
d = {'a':[1,2,3]}
df = pd.DataFrame(d)

df.to_sql('newcmc', con = engine, if_exists='append',index = False) 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文