Reputation: 73
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
Upvotes: 3
Views: 2904
Reputation: 23171
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
Upvotes: 8