Skip to content
Advertisement

How do I loop through a pandas dataframe, check to see if the data type of each column is a float number, then replace null values with mean?

I am trying to iterate through a pandas Dataframe which has columns with different data types, and replace them with different data types based on their null values.

JavaScript

This code did not work as the null values are not replaced in the dataframe.

Advertisement

Answer

fillna() doesn’t normaly edit your dataframe. you have 2 ways:

JavaScript

or:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement