我想重塑一个向量到一个数组的Python NumPy的:重塑已被弃用
myArray = np.reshape(myVector,[nCol,nRow])
但我得到一个警告折旧:
FutureWarning: reshape is deprecated and will raise in a subsequent release. Please use .values.reshape(...) instead
return reshape(newshape, order=order)
当我使用
myArray = np.values.reshape(myVector,[nCol,nRow])
我收到一条错误
AttributeError: module 'numpy' has no attribute 'values'
请有人可以解释发生了什么,我应该做什么?非常感谢
这不是numpy的警告。 'myVector'是一个熊猫物体吗? –
@WarrenWeckesser是的,myVector是来自更大数据框的一列。对不起,我忽略了 – jlt199
你需要在重塑它之前访问numpy数组对象然后'np.reshape(myVector.values,(nCol,nRow))' – Psidom