text_plain_output_1.png
from scipy import stats

import matplotlib.pyplot as plt

import numpy as np # linear algebra

import pandas as pd

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

import seaborn as sns

import seaborn as sns

import pandas as pd
train = pd.read_csv('../input/train.csv')
test = pd.read_csv('../input/test.csv')

train.isnull().any().sum()

train.columns[train.isnull().any()]

missing = train.isnull().sum() / len(train)
missing = missing[missing > 0]
missing.sort_values(inplace=True)
missing

missing = pd.DataFrame(missing)
missing.columns = ['count']
missing.index.names = ['name']
missing['name'] = missing.index

plt.xticks(rotation=90)

target = np.log(train['SalePrice'])

numeric_data = train.select_dtypes(include=[np.number])
cat_data = train.select_dtypes(exclude=[np.number])

numeric_data.drop('Id', axis=1, inplace=True)

corr = numeric_data.corr()

pivot = train.pivot_table(index='OverallQual', values='SalePrice', aggfunc='median')

train.GarageCars.unique()
pivot = train.pivot_table(index='GarageCars', values='SalePrice', aggfunc='median')

cat = [f for f in train.columns if train.dtypes[f] == 'object']
def anova(frame):
    anv = pd.DataFrame()
    anv['features'] = cat
    pvals = []
    for c in cat:
        samples = []
        for cls in frame[c].unique():
            s = frame[frame[c] == cls]['SalePrice'].values
            samples.append(s)
        pval = stats.f_oneway(*samples)[1]
        pvals.append(pval)
    anv['pval'] = pvals
    return anv.sort_values('pval')
cat_data['SalePrice'] = train.SalePrice.values
k = anova(cat_data)
k['disparity'] = np.log(1.0 / k['pval'].values)
sns.barplot(data=k, x='features', y='disparity')
plt.xticks(rotation=90)
plt