2017-03-09 7 views
3

を推奨されていません、私は配列Pythonのnumpyの:リシェイプが

myArray = np.reshape(myVector,[nCol,nRow]) 

にベクトルを再構築しようとしているが、私は減価償却の警告を得る:私は

myArray = np.values.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) 

エラーが発生します

AttributeError: module 'numpy' has no attribute 'values' 

誰かが何が起こっているのか、私は何をすべきか説明できますか?多くのありがとう

+6

numpyの警告されていないこと。 'myVector'はパンダオブジェクトですか? –

+0

@WarrenWeckesserはい、myVectorは大きなデータフレームの1つの列です。申し訳ありませんが私はそれを見逃した – jlt199

+0

numpy配列オブジェクトにアクセスする必要がありますそれから 'np.reshape(myVector.values、(nCol、nRow))' – Psidom

答えて

3

np.reshape(どんなargs)も、もはや関数を呼び出すのに好ましい方法ではありません。私はこれを使用して、私の問題を解決した

myArray = myVector.values.reshape([nCol,nRow])

+1

ちょうど指摘されている問題とは無関係ですが、これはnumbaによってサポートされていません – muon

0

:あなたの特定のケースで

train_set_X = train_df["STRAIGHT_DIST"] 
train_set_X_np = np.array(train_set_X) 
train_set_X_np = train_set_X_np.reshape([train_set_X.shape[0], 1]) 

、あなたがこれを使用する必要があります。代わりに、これを使用する

myVector_np = np.array(myVector) 
myVector_np = myVector_np.reshape([myVector.shape[0], 1])