# [Tutor] To show the result on a map

subodh.khandelwal at gmail.com subodh.khandelwal at gmail.com
Sun Mar 6 18:10:18 EST 2022

```Hello,

I am very new to Python with basic understanding to programming. Currently I
am doing a project on a dataset of crimes in Seattle which has the following
columns:

ID | Offense_Grp | Offense_code | Block_Add | Precint | Report_Number |
Longitude | Latitude | Offense | Area_Name | Offense_start_date_time .

I have written a code which gives the top 10 most unsafe areas and 10 most
safe areas in Seattle based on the number of crimes there. I would like to
plot these on the map of Seattle.

The code I have written in Jupyter notebook is:

import pandas as pd

from shapely.geometry import point

import numpy as np

import matplotlib as mpl

import matplotlib.pyplot as plt

import geopandas as gpd

from geopandas import GeoDataFrame

import geopy

from geopy.geocoders import Nominatim

import folium

from geopy.extra.rate_limiter import RateLimiter

from folium import plugins

from folium.plugins import MarkerCluster

import seaborn as sns

# to count the number of offenses

df.offense.value_counts().iloc[:100]

# to list the top 10 crimes in Seattle

max_crimes = df.offense.value_counts().nlargest(10)

max_crimes

# to show the top 10 crimes in a bar chart

df.offense.value_counts().iloc[:10].sort_values().plot(kind= 'barh')

# to show the top 10 unsafe areas in seattle with the most number of crimes
in a pie chart

df.Area_Name.value_counts().iloc[:10].sort_values().plot(kind= 'pie')

# to list the most 10 unsafe areas in Seattle

most_unsafe = df.Area_Name.value_counts().nlargest(10)

most_unsafe

# to list the most 10 safe areas in Seattle

most_safe = df.Area_Name.value_counts().nsmallest(10)

most_safe

I would like to show the most_unsafe and most_safe areas in the map of