<jupyter_start><jupyter_text><jupyter_code>import numpy as np
import pandas as pd
import seaborn as sns
import requests
import io
from google.colab import drive
drive.mount('/content/drive')
df=pd.read_csv('/content/drive/MyDrive/1..Zomato Spatial Analysis/zomato.csv')
df.head()
df.isna().sum()
df.shape

df.dropna(axis=0,subset=['location'],inplace=True)
df.isna().sum()
len(df['location'].unique())
df.location.value_counts()
location=pd.DataFrame()
location['names']=df['location'].unique()
location.head()
!pip install geopy
from geopy.geocoders import Nominatim
geolocator=Nominatim(user_agent='app')
lat=[]
lon=[]
for location1 in location['names']:
  location1=geolocator.geocode(location1)
  if location1 is None:
    lat.append(np.nan)
    lon.append(np.nan)
  else:
    lat.append(location1.latitude)
    lon.append(location1.longitude)

location['lat']=lat
location['lon']=lon
location.head(10)
location.to_csv('/content/drive/MyDrive/zomato_location.csv',index=False)
rest_location=df['location'].value_counts().reset_index()
rest_location.columns=['names','counts']
rest_location.head()

merged_df=pd.merge(location,rest_location,on='names').sort_values(by=['counts'],ascending=False)
merged_df.reset_index(inplace=True)
merged_df.isna().sum()
merged_df.dropna(inplace=True)

def gen_basemap(default_location=[12.97,77.59],default_zoom_start=12):
  basemap=folium.Map(location=default_location,zoom_start=default_zoom_start)
  return basemap
import folium
base=gen_basemap()
base
!pip uninstall folium
!pip install folium==0.10.0


from folium.plugins import HeatMap

merged_df.drop('index',inplace=True,axis=1)
merged_df
import sys
print(sys.getrecursionlimit())
sys.setrecursionlimit(10000)
heated=merged_df[['lat','lon','counts']]
heated[:1]
HeatMap(heated,max_zoom=20).add_to(base)
base
from folium.plugins import FastMarkerCluster
FastMarkerCluster(heated,max_zoom=20).add_to(base)
base
df.head()
df['rate'].unique()
df.dropna(subset=['rate'],inplace=True)
df=df[df['rate']!='NEW']
df=df[df['rate']!='-']
df['rate'].unique()




r=[float(str(i).split('/')[0]) for i in df['rate']]
r
df['ratings']=r
df.head()
rating_df=df.groupby(by='location').mean()
merged_df.head()
rating_df.reset_index(inplace=True)
rating_df.head()
rating_df.columns=['names','votes','ratings']
merged_df_new=pd.merge(merged_df,rating_df,on='names').sort_values(by=['ratings'],ascending=False)
merged_df_new.head()
merged_df_new.isna().sum()
heated1=merged_df_new[['lat','lon','ratings']]
HeatMap(heated1,max_zoom=20).add_to(base)
base
df.head()
df_north=df[df['cuisines']=='North Indian']
df_north.groupby('location')['url'].count()
def heatmapper(zone):
  filter=df['cuisines']==zone
  df2=df[filter]
  zonal=df2.groupby('location')['url'].count().reset_index()
  zonal.columns=['names','count_regional']  
  zonal=zonal.merge(merged_df,on='names').dropna()
  heated1=zonal[['lat','lon','count_regional']]
  HeatMap(heated1,max_zoom=20).add_to(base)
  return base

heatmapper('Chinese')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1813953488372093, 'fraction_numerical': 0.015282392026578074, 'mean_word_length': 9.172297297297296, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '644408', 'license': 'Apache-2.0', 'n_tokens_mistral': 1198, 'n_tokens_neox': 1140, 'n_words': 145, 'path': 'zomato_geo.ipynb', 'repo_name': 'vedantkathe846/Geospatial_zomato', 'size': '3010'}