报错‘function’object has no attribute‘XXXX’

报错原因:可能是方法后面没有加 ( )

# train_x为dataframe
train_X=train_x.to_numpy
train_X=train_X.reshape((train_X.shape[0],train_X.shape[1],1))

#运行结果
 2 train_X=train_x.to_numpy
----> 3 train_X=train_X.reshape(())

AttributeError: 'function' object has no attribute 'reshape'

正确写法:

train_X=train_x.to_numpy()
train_X=train_X.reshape((train_X.shape[0],train_X.shape[1],1))

运行成功

以前不曾注意到的错误,细心啊!细心!

你可能感兴趣的:(numpy,python,开发语言)