<jupyter_start><jupyter_text>IMPORTS<jupyter_code>import cv2
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import geopandas as gpd
import geoplot as gplt
from shapely.geometry import Point,Polygon<jupyter_output><empty_output><jupyter_text>DATA preprocessing and dataframe<jupyter_code>import geopandas as gpd
geodf= gpd.read_file('neighbourhoods.geojson')
geodf["area"] = geodf['geometry'].area/ 10**6
df = pd.read_csv('listings.csv')
mapping = dict(geodf[['neighbourhood', 'geometry']].values)
df['geometry'] = df.neighbourhood.map(mapping)
mapping = dict(geodf[['neighbourhood', 'area']].values)
df['area'] = df.neighbourhood.map(mapping)
# Import label encoder
from sklearn import preprocessing
# label_encoder object knows how to understand word labels.
label_encoder = preprocessing.LabelEncoder()
# Encode labels in column 'species'.
df['room_type']= label_encoder.fit_transform(df['room_type'])
df = df.drop(['neighbourhood_group'],axis= 1)
geo = [Point(xy) for xy in zip( df['longitude'], df['latitude'])]
gdf = gpd.GeoDataFrame(df,geometry = geo)

df.head()
geodf.head()
gdf.head()<jupyter_output><empty_output><jupyter_text>A. Mapping the data listing and nighbourhood and top areas<jupyter_code>import matplotlib.pyplot as plt
fig, ax = plt.subplots(1, 1, figsize=(16, 12))

# Set up the color sheme:
import mapclassify as mc
scheme = mc.Quantiles(df['area'], k=10)

# Map
gplt.choropleth(geodf, 
    hue="area", 
    linewidth=.1,
    scheme=scheme, cmap='inferno_r',
    legend=True,
    edgecolor='black',
    ax=ax
);

ax.set_title('TOP areas', fontsize=13);<jupyter_output><empty_output><jupyter_text>B. Thematic map for neighbourhood<jupyter_code>fig,ax = plt.subplots(figsize = (15,15))
geodf.plot(ax= ax ,alpha=0.4 ,color = 'grey')
gdf[gdf['room_type'] == 0].plot(ax =ax,markersize = 20, color = 'blue',marker = "o",label="Entire Room" )
gdf[gdf['room_type'] == 2].plot(ax=ax,markersize = 20, color = 'red',marker ="^",label = "Private Room")
plt.legend(prop ={'size':15})<jupyter_output><empty_output><jupyter_text>TOP 10 Hosts<jupyter_code>frequency = df['neighbourhood'].value_counts()
freq = df['host_id'].value_counts()
print('top host id areas:')
print(freq[:10])
print('top 10 areas:')
print(frequency[:10])<jupyter_output>top 10 areas:
Near North Side    749
West Town          685
Lake View          583
Logan Square       377
Loop               358
Near West Side     353
Lincoln Park       289
Near South Side    181
Lower West Side    173
Uptown             170
Name: neighbourhood, dtype: int64
{'fraction_non_alphanumeric': 0.14106583072100312, 'fraction_numerical': 0.02821316614420063, 'mean_word_length': 5.6484375, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '428186', 'license': 'MIT', 'n_tokens_mistral': 990, 'n_tokens_neox': 927, 'n_words': 213, 'path': 'Assignment.ipynb', 'repo_name': 'I-am-sayantan/Make-Thematic-plot-using-Geojson-and-CSV', 'size': '2552'}