AttributeError: ‘list‘ object has no attribute ‘to_excel‘

df 获取的数据往往不能直接用于保存到excel中,需要用pd.DataFrame()对数据进行转换。

如:
df = result
df.to_excel(new_wb, sheet_name=sheet_name, index=False)

报错:
AttributeError: 'list' object has no attribute 'to_excel'

正确写法如下:

df = pd.DataFrame(result)
df.to_excel(new_wb, sheet_name=sheet_name, index=False)

你可能感兴趣的:(pandas,python,数据分析)