我正在尝试将数据框的形状打印到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'
答案 0 :(得分:0)
尝试以下操作:
file_shape = df.shape[0] # <<-- This saves the count of rows to a variable
df['file_shape'] = file_shape
writer = pd.ExcelWriter(output, engine='xlsxwriter')
df.to_excel(writer, startrow=0, merge_cells=False, sheet_name="Summary", index=False)