Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'Series' object has no attribute 'reshape' #2

Open
Heiwater opened this issue Apr 2, 2021 · 1 comment
Open

AttributeError: 'Series' object has no attribute 'reshape' #2

Heiwater opened this issue Apr 2, 2021 · 1 comment

Comments

@Heiwater
Copy link

Heiwater commented Apr 2, 2021

just as the title saying

when i try to running the code,the ide reoprt this

Traceback (most recent call last):
  File "/home/heiwater/Note/ML/Lenet5/LeNet-5-with-Keras/lenet_5.py", line 19, in <module>
    sample = sample.reshape([28,28])
  File "/home/heiwater/.local/lib/python3.8/site-packages/pandas/core/generic.py", line 5465, in __getattr__
    return object.__getattribute__(self, name)
AttributeError: 'Series' object has no attribute 'reshape'

i had tried search it on google,some of then said chage the code in line26
from

X_train = X_train.reshape(X_train.shape[0], 28, 28, 1)

to

X_train = X_train.value.reshape(X_train.shape[0], 28, 28, 1)

but it dosn't work

i have already try to run it on the Windows 10 and Ubuntu 20.04,they report the same error
and my python version is 3.8.5 my panda version is 1.2.3

it's my pleasure if some one can help me :)

@SP2203
Copy link

SP2203 commented Apr 26, 2021

Hey @Heiwater, if you look at the error code it clearly states the variable sample is the Pandas series. Pandas series does not have attribute reshape associated with it. What you could do is instead of

sample = sample.reshape([28,28]) on line 19 change the sample to numpy array

sample = np.array(sample).reshape([28,28])

This should work for you as numpy array has the attribute reshape

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants