Pandas df.to_stata():“DataFrame”对象没有属性“dtype”

xxg*_*yxx 6 python dataframe stata pandas

到目前为止,pandas 函数df.to_stata()对我的数据集运行得很好。

我正在尝试使用以下代码将包含 29,778 行和 37 行的数据框导出到 Stata 文件:

df.to_stata("Stata_File.dta", write_index=False, version=118)
Run Code Online (Sandbox Code Playgroud)

但是,我收到以下错误消息:

AttributeError: 'DataFrame' object has no attribute 'dtype'
Run Code Online (Sandbox Code Playgroud)

我真的很感激任何帮助如何解决这个问题。

Wou*_*ter 4

当数据框中具有相同名称的多个列时,可能会出现此错误