In [1]:
from __future__ import division, print_function, unicode_literals
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
In [4]:
foreclosure_accum_df = pd.read_csv('ihs_data/IHS_Foreclosure_Accumulation_chicago-community-areas.csv')
foreclosure_accum_df['Percentage_Foreclosed_Parcels'] = foreclosure_accum_df['Percentage_Foreclosed_Parcels'].str[:-1].astype(float)
foreclosure_accum_df.head()
Out[4]:
In [10]:
foreclosure_filings_df = pd.read_csv('ihs_data/IHS_Foreclosure_Filings_chicago-community-areas.csv')
foreclosure_filings_df = foreclosure_filings_df.fillna(0)
foreclosure_filings_df['Foreclosure_Filings_05_15'] = foreclosure_filings_df[['All_Res_2005', 'All_Res_2006', 'All_Res_2007',
'All_Res_2008', 'All_Res_2009', 'All_Res_2010',
'All_Res_2011', 'All_Res_2012', 'All_Res_2013',
'All_Res_2014', 'All_Res_2015']].sum(axis=1)
foreclosure_filings_df = foreclosure_filings_df[['Community_Area', 'Foreclosure_Filings_05_15']]
foreclosure_filings_df.head()
Out[10]:
In [14]:
foreclosure_parcels_df = pd.read_csv('ihs_data/IHS_Foreclosures_per_Parcel_chicago-community-areas.csv')
foreclosure_parcels_df['Foreclosures_per_Parcel_Mean_05_15'] = foreclosure_parcels_df[foreclosure_parcels_df.columns.values[1:]].mean(axis=1)
foreclosure_parcels_df = foreclosure_parcels_df[['Community_Area', 'Foreclosures_per_Parcel_Mean_05_15']]
foreclosure_parcels_df.head()
Out[14]:
In [25]:
low_value_df = pd.read_csv('ihs_data/IHS_Share_Low_Value_chicago-community-areas.csv')
low_value_df = low_value_df.fillna(0)
res_columns_05_15 = ['All_Res_2005', 'All_Res_2006', 'All_Res_2007',
'All_Res_2008', 'All_Res_2009', 'All_Res_2010',
'All_Res_2011', 'All_Res_2012', 'All_Res_2013',
'All_Res_2014', 'All_Res_2015']
low_value_df[res_columns_05_15] = low_value_df[res_columns_05_15].applymap(lambda x: x[:-1]).astype(float)
low_value_df['Share_Low_Value_Mean_05_15'] = low_value_df[res_columns_05_15].mean(axis=1)
low_value_df = low_value_df[['Community_Area', 'Share_Low_Value_Mean_05_15']]
low_value_df.head()
Out[25]:
In [30]:
vacant_df = pd.read_csv('ihs_data/IHS_Share_Vacant_chicago-community-areas.csv')
vacant_df[vacant_df.columns.values[1:]] = vacant_df[vacant_df.columns.values[1:]].applymap(lambda x: x[:-1]).astype(float)
vacant_df['Vacant_Percent_Mean_10_15'] = vacant_df[vacant_df.columns.values[1:]].mean(axis=1)
vacant_df = vacant_df[['Community_Area', 'Vacant_Percent_Mean_10_15']]
vacant_df.head()
Out[30]:
In [32]:
combined_ihs_df = pd.merge(foreclosure_accum_df, foreclosure_filings_df, on='Community_Area'
).merge(foreclosure_parcels_df, on='Community_Area').merge(low_value_df, on='Community_Area'
).merge(vacant_df, on='Community_Area')
combined_ihs_df.head()
Out[32]:
In [33]:
combined_ihs_df = combined_ihs_df.rename(columns={'Community_Area':'Community Area'})
combined_ihs_df.head()
Out[33]:
In [34]:
combined_ihs_df.to_csv('ihs_data/combined_ihs_data.csv',index=False)
In [ ]: