Crossfit_Jesus
Crossfit_Jesus

Reputation: 73

A simple log of a dataframe in python : Error : 'type' object does not support item assignment

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

Answers (1)

Chris
Chris

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

Related Questions