-
-
Save abhimanyu-bitsgoa/e28b3a6f51b7418367d01773c196abda to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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