Skip to content

Instantly share code, notes, and snippets.

@calippo
Last active March 5, 2018 16:31
Show Gist options
  • Save calippo/b236e077aa97c4293445 to your computer and use it in GitHub Desktop.
Save calippo/b236e077aa97c4293445 to your computer and use it in GitHub Desktop.
[pandas] Replace `NaN` values with the mean of the column and remove all the completely empty columns
import pandas as pd
def fillWithMean(df):
return df.fillna(df.mean()).dropna(axis=1, how='all')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment