2017-03-09 2 views
3

내가 배열파이썬 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

없는 그 . 'myVector'는 팬더 객체입니까? –

+0

@WarrenWeckesser 예, myVector는 더 큰 데이터 프레임의 한 열입니다. 죄송합니다 간과 했음 – jlt199

+0

numpy 배열 객체에 액세스하기 전에 nump 배열 객체에 액세스해야합니다. '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]) 

을, 당신은이를 사용해야하십시오 NumPy와 경고가

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