Skip to content

Instantly share code, notes, and snippets.

@aniruddha27
Created March 16, 2020 10:00
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 aniruddha27/c9a06afa42c22a1fc40ee1f7a625f4af to your computer and use it in GitHub Desktop.
Save aniruddha27/c9a06afa42c22a1fc40ee1f7a625f4af to your computer and use it in GitHub Desktop.
#NA means no masonary work
train['MasVnrType'].fillna('None',inplace=True)
#If no masonary work, then area is 0
train['MasVnrArea'].fillna(0,inplace=True)
#Replace with the most common value
for i in ['MSZoning','Utilities']:
train[i].fillna(train[i].mode()[0],inplace=True)
#"Assume typical unless deductions are warranted"
train['Functional'].fillna('Typ',inplace=True)
#Replace with others
train['SaleType'].fillna('Oth',inplace=True)
#Replace with most common value
train['Electrical'].fillna(train['Electrical'].mode()[0],inplace=True)
#Replace with 'Other' value
for i in ['Exterior1st','Exterior2nd']:
train[i].fillna('Other',inplace=True)
#Replace with most common value
train['KitchenQual'].fillna(train['KitchenQual'].mode()[0],inplace=True)
#ordinal value
train['KitchenQual'].replace(['Ex','Gd','TA','Fa','Po'],[4,3,2,1,0],inplace=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment