Skip to content

Instantly share code, notes, and snippets.

@ashwinprasadme
Created December 15, 2020 04:30
Show Gist options
  • Save ashwinprasadme/8a467214e0787be17fbfb1a7da41c01a to your computer and use it in GitHub Desktop.
Save ashwinprasadme/8a467214e0787be17fbfb1a7da41c01a to your computer and use it in GitHub Desktop.
## finding all columns that have nan:
droping_list_all=[]
for j in range(0,7):
if not df.iloc[:, j].notnull().all():
droping_list_all.append(j)
#print(df.iloc[:,j].unique())
droping_list_all
# filling nan with mean in any columns
for j in range(0,7):
df.iloc[:,j]=df.iloc[:,j].fillna(df.iloc[:,j].mean())
# another sanity check to make sure that there are not more any nan
df.isnull().sum()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment