Skip to content

Instantly share code, notes, and snippets.

@dradecic
Created September 9, 2019 13:46
Show Gist options
  • Save dradecic/564c3a9de955ef972b74575f2b700920 to your computer and use it in GitHub Desktop.
Save dradecic/564c3a9de955ef972b74575f2b700920 to your computer and use it in GitHub Desktop.
ara_4_coarse_classing
def coarse_classer(df, indexloc_1, indexloc_2):
mean_val = pd.DataFrame(np.mean(pd.DataFrame([df.iloc[indexloc_1], df.iloc[indexloc_2]]))).T
original = df.drop([indexloc_1, indexloc_2])
coarsed_df = pd.concat([original, mean_val])
coarsed_df = coarsed_df.sort_values(by='WoE', ascending=False).reset_index(drop=True)
return coarsed_df
geography_df = coarse_classer(geography_df, 1, 2)
geography_df
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment