将数据帧的输出保存到ex时发生Python错误

2024-05-14 10:50:10 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试将数据框的形状打印到excel文件中。你知道吗

以下是我迄今为止所取得的成就:

file_shape = df.shape[0] <<-- This saves the count of rows to a variable
writer = pd.ExcelWriter(output, engine='xlsxwriter')
file_shape.to_excel(writer, startrow=0, merge_cells=False, sheet_name="Summary", index=False)

上面的抛出一个错误

AttributeError: 'int' object has no attribute 'to_excel'

Tags: 文件theto数据falsedfcountthis

热门问题