'Int64Index' object has no attribute 'reshape'
Posted yimiyan
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了'Int64Index' object has no attribute 'reshape'相关的知识,希望对你有一定的参考价值。
python机器学习基础教程,P187
书中:
X= citibike.index.strftime("%s").astype("int").reshape(-1,1)
报错:
Int64Index([1438358400, 1438369200, 1438380000, 1438390800, 1438401600, 1438412400, 1438423200, 1438434000, 1438444800, 1438455600, ... 1440928800, 1440939600, 1440950400, 1440961200, 1440972000, 1440982800, 1440993600, 1441004400, 1441015200, 1441026000], dtype=‘int64‘, length=248) Traceback (most recent call last): File "/Users/tusvn/PycharmProjects/practice/citibike_feature_select_test.py", line 12, in <module> X= citibike.index.strftime("%s").astype("int").reshape(-1,1) AttributeError: ‘Int64Index‘ object has no attribute ‘reshape‘
修改:
X= citibike.index.strftime("%s").astype("int").values.reshape(-1,1)
以上是关于'Int64Index' object has no attribute 'reshape'的主要内容,如果未能解决你的问题,请参考以下文章
TypeError: Object of type 'int32' is not JSON serializable ——已解决
对象类型为'int64'的叶子热图不是JSON可序列化的错误
Python的pandas 数组如何得到索引值,如图,我要得到ohio 的索引值,应该怎样做?
The expected type was 'System.Int64' but the actual value was null.”