Created
April 24, 2016 20:08
-
-
Save dengjonathan/55c24aaf5999eca102365b653acf4d01 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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