AttributeError: 'Series' object has no attribute 'as_matrix'

When I execute the code of the official website, I get such an error. Why?
code show as follow:

landmarks_frame = pd.read_csv(‘F:\OfficialData\faces\face_landmarks.csv’)

n = 65
img_name = landmarks_frame.iloc[n, 0]
landmarks = landmarks_frame.iloc[n, 1:].as_matrix()
landmarks = landmarks.astype(‘float’).reshape(-1, 2)

print(‘Image name: {}’.format(img_name))
print(‘Landmarks shape: {}’.format(landmarks.shape))
print(‘First 4 Landmarks: {}’.format(landmarks[:4]))

Which line of code is raising this error and which pandas version are you using?
I just tried to reproduce the issue, but the code works fine using pandas==0.25.3.

1 Like

“landmarks = landmarks_frame.iloc[n, 1:].as_matrix()”
The above code runs with errors.

The version of pandas is 1.0.1.
Replace ‘as_matrix()’ with ‘to_numpy()’ and the problem is solved.

3 Likes

I used the code from the tutorial, which is using np.asarray and didn’t realize you’ve changed the code.
Anyway, good to hear it’s working now.

thanks, it works for me too