pandas DataFrame.as_matrix() 出错
原数据df = pd.DataFrame(pd.read_excel(r'C:\Users\chenj\Desktop\测试用.xlsx'))
print(df)
显示:
序号天气周末促销销量
0 1 1 1 1 1
1 2-1-1 1 1
2 3 1 1-1 1
3 4 1-1 1-1
4 5 1-1-1 1
5 6-1-1 1-1
6 7-1-1-1 1
7 8-1-1-1 1
8 9-1 1-1 1
9 10-1 1 1-1
1011 1 1 1-1
1112 1 1-1 1
1213-1-1 1-1
x=df.iloc[:,:4].as_matrix()
y=df.iloc[:,4].as_matrix()
打算做决策树分析,把销量和前面的几项进行分析
运行后,显示
File "D:/Python/projects/test2", line 13, in <module>
x=df.iloc[:,:4].as_matrix()
File "D:\Python\projects\venv\lib\site-packages\pandas\core\generic.py", line 5139, in __getattr__
return object.__getattribute__(self, name)
AttributeError: 'DataFrame' object has no attribute 'as_matrix'
请教,应该如何修改
据说是as_matrix()被淘汰了,换成了values
x=df.iloc[:,:4].values
楼上正解
页:
[1]