Skip to content

Instantly share code, notes, and snippets.

@abhimanyu-bitsgoa
Last active March 6, 2018 09:18
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/4846f98026e162af80b7df6a98e73353 to your computer and use it in GitHub Desktop.
Save abhimanyu-bitsgoa/4846f98026e162af80b7df6a98e73353 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
from matplotlib.pyplot import pie, axis, show
%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)
#Summing up the houses
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['Side_Walk'] = test_frame['Side_Walk'].astype(int)
sums = test_frame.Side_Walk.groupby(test_frame.House_Type).sum()
#Plotting the data
sns.set_style("whitegrid")
sns.set_context("poster")
ax = sns.barplot(x=sums.index, y=sums, data=test_frame)
ax.set(xlabel='House Type', ylabel='Number of houses with Side Walks')
plt.title('No of houses of various classes having Sidewalks')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment