pandas.DataFrame.to_excel

来源:互联网 发布:炒股软件免费版排名 编辑:程序博客网 时间:2024/06/05 05:16

将python中的一列元素输出到excel,

出现如下错误

AttributeError: 'numpy.ndarray' object has no attribute 'to_excel'

查阅资料:http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.to_excel.html


发现to_excel()函数必须用在Dataframes类型,

所以

yy=pd.DataFrame(yy)
writer=pd.ExcelWriter("D:/Users/dauron/Desktop/output1.xlsx")
yy.to_excel(writer,'Sheet1')
writer.save()

问题解决。


原创粉丝点击