Skip to content

Instantly share code, notes, and snippets.

@dengjonathan
Created April 24, 2016 20:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dengjonathan/55c24aaf5999eca102365b653acf4d01 to your computer and use it in GitHub Desktop.
Save dengjonathan/55c24aaf5999eca102365b653acf4d01 to your computer and use it in GitHub Desktop.
def useless_columns(df):
"""Returns list of columns with less than 30 not null values"""
columns = []
for col in df.columns:
# isnull returns a list-like object with True is an element in the column is NaN and False if element has value
null_list = pd.isnull(df[col])
real_values = len([i for i in null_list if i != True])
if real_values < 30:
columns.append(col)
return columns
super_df.drop(useless_columns(super_df), axis=1, inplace=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment