Welcome to the Simplilearn Community

Want to join the rest of our members? Sign up right away!

Sign Up

California House Pricing Project

Kevon

New Member
Hi,
I am trying to replace the missing values with the respective mean of a specific column. However, when I do that it is returning to me as a function and not an integer or float.

My code is as follows:
x_feature.total_bedrooms.fillna(np.mean, inplace = True)

the result it gave is:
<function mean at 0x7fd45c5bd200>

So I then tried to convert this function into a numeric value with the code:
x_features['total_bedrooms'] = pd.to_numeric(x_features['total_bedrooms'], errors='raise')
x_features.dtypes

It is giving me the error:
TypeError: Invalid object type at position 290

Can anyone help me, please?
 

Attachments

  • Screen Shot 2020-08-28 at 11.54.01 AM.png
    Screen Shot 2020-08-28 at 11.54.01 AM.png
    58.4 KB · Views: 1
Top