3

I am trying to take a log of a dataframe and copy it into a new dataframe in Python and I get this error : 'type' object does not support item assignment

import math
y = pd.DataFrame
y['Number'] = np.log(df.Number)
y

1 Answer 1

8

Right now you're setting y to the DataFrame class, not an instance of it. You need to call the constructor to create a new dataframe:

y = pd.DataFrame()

then your assignment should work

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.