Skip to content

Instantly share code, notes, and snippets.

@abhimanyu-bitsgoa
Last active March 6, 2018 12:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abhimanyu-bitsgoa/e28b3a6f51b7418367d01773c196abda to your computer and use it in GitHub Desktop.
Save abhimanyu-bitsgoa/e28b3a6f51b7418367d01773c196abda to your computer and use it in GitHub Desktop.
#Import statements to get required modules
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
import seaborn as sns
import math
#Loading the dataset into a dataframe
df=pd.read_csv('./Housing_Dataset.csv',encoding ='latin1')
dic={'House_Type':df['house_types'],'Side_Walk':df['sidewalk_ok']}
test_frame=pd.DataFrame(dic)
# Aggregating the results
dic1={'Residence':df['residential_yes']}
test_frame
test_frame=test_frame.dropna(axis=0, how='any')
mymap = {'yes':1, 'no':0,'Not sure, mixed':0}
test_frame=test_frame.dropna(axis=0, how='any')
test_frame = test_frame.reset_index(drop=True)
test_frame=test_frame.applymap(lambda s: mymap.get(s) if s in mymap else s)
test_frame['Residence']=pd.DataFrame(dic1)
# Plotting the results
sns.set_context("poster")
sns.factorplot(x="House_Type", y="Side_Walk", hue="Residence", data=test_frame, kind="bar",size=4, aspect=4)
plt.xlabel('House_Type')
plt.ylabel('Fraction of houses having SideWalk')
plt.title('Fraction of residential and non residential houses having SideWalk per class')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment