成功解决AttributeError: ‘DataFrame‘ object has no attribute ‘tolist‘
生活随笔
收集整理的這篇文章主要介紹了
成功解决AttributeError: ‘DataFrame‘ object has no attribute ‘tolist‘
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
成功解決AttributeError: 'DataFrame' object has no attribute 'tolist'
目錄
解決問題
解決思路
解決方法
解決問題
return object.__getattribute__(self, name)
AttributeError: 'DataFrame' object has no attribute 'tolist'
解決思路
屬性錯誤:“DataFrame”對象沒有屬性“tolist”
解決方法
切記,DataFrame沒有tolist()方法,而series.Series有tolist()方法,故需要修改
將
import pandas as pd#讀取xls文件 file_path='data/test1226.xls' data_frame_xls=pd.read_excel(file_path) data_df01 = data_frame_xls[['age']] print(type(data_df01)) print(res)改為
import pandas as pd#讀取xls文件 file_path='data/test1226.xls' data_frame_xls=pd.read_excel(file_path) data_df01 = data_frame_xls[['age']] print(type(data_df01))data_df01 = data_frame_xls['age'] print(type(data_df01 )) res = data_df01 .tolist() print(res)哈哈,大功告成!
總結
以上是生活随笔為你收集整理的成功解决AttributeError: ‘DataFrame‘ object has no attribute ‘tolist‘的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Python之Pandas:利用Pand
- 下一篇: Dataset:GiveMeSomeCr