text_plain_output_1.png image_output_1.png
import matplotlib.pyplot as plt

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import seaborn as sns

data = pd.read_csv('../input/airbnbnewyork/listings.csv')

data.shape

data.isnull().sum()

data.drop(['id', 'host_name', 'last_review'], axis=1, inplace=True)

data.fillna({'reviews_per_month': 0}, inplace=True)
data.reviews_per_month.isnull().sum()

data.neighbourhood_group.unique()

len(data.neighbourhood.unique())

data.room_type.unique()

#we will skip first column for now and begin from host_id

#let's see what hosts (IDs) have the most listings on Airbnb platform and taking advantage of this service
top_host=data.host_id.value_counts().head(10)
top_host

top_host_check = data.calculated_host_listings_count.max()
top_host_check

sns.set(rc={'figure.figsize': (10, 8)})
sns.set_style('white')

top_host_df = pd.DataFrame(top_host)
top_host_df.reset_index(inplace=True)
top_host_df.rename(columns={'index': 'Host_ID', 'host_id': 'P_Count'}, inplace=True)
top_host_df

viz_1=sns.barplot(x="Host_ID", y="P_Count", data=top_host_df,
                 palette='Blues_d')
viz_1.set_title('Hosts with the most listings in NYC')
viz_1.set_ylabel('Count of listings')
viz_1.set_xlabel('Host IDs')
viz_1.set_xticklabels(viz_1.get_xticklabels(), rotation=45)

sub_1 = data.loc[data['neighbourhood_group'] == 'Brooklyn']
price_sub1 = sub_1[['price']]
sub_2 = data.loc[data['neighbourhood_group'] == 'Manhattan']
price_sub2 = sub_2[['price']]
sub_3 = data.loc[data['neighbourhood_group'] == 'Queens']
price_sub3 = sub_3[['price']]
sub_4 = data.loc[data['neighbourhood_group'] == 'Staten Island']
price_sub4 = sub_4[['price']]
sub_5 = data.loc[data['neighbourhood_group'] == 'Bronx']
price_sub5 = sub_5[['price']]
price_list_by_n = [price_sub1, price_sub2, price_sub3, price_sub4, price_sub5]

#we can see from our statistical table that we have some extreme values, therefore we need to remove them for the sake of a better visualization

#creating a sub-dataframe with no extreme values / less than 500
sub_6=data[data.price < 500]
#using violinplot to showcase density and distribtuion of prices 
viz_2=sns.violinplot(data=sub_6, x='neighbourhood_group', y='price')
viz_2.set_title('Density and distribution of prices for each neighberhood_group')

viz_4 = sub_6.plot(kind='scatter', x='longitude', y='latitude', label='availability_365', c='price', cmap=plt.get_cmap('jet'), colorbar=True, alpha=0.4, figsize=(10, 8))
viz_4.legend()