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

app_train = pd.read_csv('../input/application_train.csv')

app_test = pd.read_csv('../input/application_test.csv')

def missing_values_table(df):
    """
    Function to calculate missing values by column
    Arguments:
        df: dataframe
    Output:
        miss_val_table_renamed_cols: dataframe with missing values
    """
    miss_value = df.isnull().sum()
    miss_value_pct = 100 * df.isnull().sum() / len(df)
    miss_val_table = pd.concat([miss_value, miss_value_pct], axis=1)
    miss_val_table_renamed_cols = miss_val_table.rename(columns={0: 'Missing Values', 1: '% of Total Values'})
    miss_val_table_renamed_cols = miss_val_table_renamed_cols[miss_val_table_renamed_cols.iloc[:, 1] != 0].sort_values('% of Total Values', ascending=False).round(1)
    return miss_val_table_renamed_cols

app_train.dtypes.value_counts()

app_train.select_dtypes('object').apply(pd.Series.nunique, axis=0)

app_train = pd.get_dummies(app_train)
app_test = pd.get_dummies(app_test)

train_labels = app_train['TARGET']
app_train, app_test = app_train.align(app_test, join='inner', axis=1)
app_train['TARGET'] = train_labels

anom = app_train[app_train['DAYS_EMPLOYED'] == 365243]
non_anom = app_train[app_train['DAYS_EMPLOYED'] != 365243]
print('The non-anomalies default on %0.2f%% of loans' % (100 * non_anom['TARGET'].mean()))
print('The anomalies default on %0.2f%% of loans' % (100 * anom['TARGET'].mean()))
print('There are %d anomalous days of employment' % len(anom))