目录
解决问题
return object.__getattribute__(self, name)
AttributeError: 'DataFrame' object has no attribute 'tolist'
解决思路
属性错误:“DataFrame”对象没有属性“tolist”
解决方法
切记,DataFrame没有tolist()方法,而series.Series有tolist()方法,故需要修改
将
1. import pandas as pd 2. 3. #读取xls文件 4. file_path='data/test1226.xls' 5. data_frame_xls=pd.read_excel(file_path) 6. data_df01 = data_frame_xls[['age']] 7. print(type(data_df01)) 8. print(res)
改为
1. import pandas as pd 2. 3. #读取xls文件 4. file_path='data/test1226.xls' 5. data_frame_xls=pd.read_excel(file_path) 6. data_df01 = data_frame_xls[['age']] 7. print(type(data_df01)) 8. 9. data_df01 = data_frame_xls['age'] 10. print(type(data_df01 )) 11. res = data_df01 .tolist() 12. print(res)
哈哈,大功告成!