text_plain_output_1.png
import matplotlib.pyplot as plt

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import seaborn as sns

df = pd.read_csv('../input/house-prices-advanced-regression-techniques/train.csv')

def NanColums(df):
    percent_nan = 100 * df.isnull().sum() / len(df)
    percent_nan = percent_nan[percent_nan > 0].sort_values()
    return percent_nan
nanColums = NanColums(df)
plt.xticks(rotation=90)

df[['Electrical', 'MasVnrType']] = df[['Electrical', 'MasVnrType']].fillna('None')
df[['MasVnrArea']] = df[['MasVnrArea']].fillna(0)
str_cols = ['GarageType', 'GarageFinish', 'GarageQual', 'GarageCond', 'BsmtQual', 'BsmtCond', 'BsmtFinType1', 'BsmtFinType2', 'BsmtExposure']
df[str_cols] = df[str_cols].fillna('None')
df['GarageYrBlt'] = df['GarageYrBlt'].fillna(0)
df.drop(['Fence', 'Alley', 'MiscFeature', 'PoolQC'], axis=1, inplace=True)
df['FireplaceQu'] = df['FireplaceQu'].fillna('None')
df['LotFrontage'] = df.groupby('Neighborhood')['LotFrontage'].transform(lambda val: val.fillna(val.mean()))
'del df["Alley"] #91 delete due to almost all ia NaN\ndel df["PoolQC"] #7\ndel df["MiscFeature"] #54\n\n\ndf["MasVnrType"].fillna(value="0", inplace=True) # 1452\ndf["MasVnrArea"].fillna(value=0.0, inplace=True) # 1452\ndf["BsmtQual"].fillna(value="0", inplace=True) # 1423\ndf["BsmtCond"].fillna(value="0", inplace=True) # 1423\ndf["BsmtExposure"].fillna(value="0", inplace=True) # 1422\ndf["BsmtFinType1"].fillna(value="0", inplace=True) # 1423\ndf["BsmtFinType2"].fillna(value="0", inplace=True) # 1422\ndf["FireplaceQu"].fillna(value="0", inplace=True) #770\n\ndf["Electrical"].fillna(value="0", inplace=True) #1459\ndf["GarageType"].fillna(value="0", inplace=True) #1379   осутствие логично закодировать нулем\ndf["GarageYrBlt"].fillna(value=0.0, inplace=True) # 1379\ndf["GarageFinish"].fillna(value="0", inplace=True) #1379\ndf["GarageQual"].fillna(value="0", inplace=True) #1379\ndf["GarageCond"].fillna(value="0", inplace=True) #1379\ndf["Fence"].fillna(value="0", inplace=True) #281\n\ndf[\'LotFrontage\'] = df.groupby(\'Neighborhood\')[\'LotFrontage\'].transform(lambda val: val.fillna(val.mean()))\n\n#categ data\n#df = pd.get_dummies(df)'

sns.heatmap(df.corr(), xticklabels=True, yticklabels=True)
plt.show()