Visualizations are very powerful tools for any data science project. It helps the reader to understand what is happening. For some dataset it is very helpful to be able to see the data on a map for presenting insights also while doing the analysis.
There are a lot of packages out there which can achieve this goal, all with their respective strengths and weaknesses. Namely Folium, Plotly, Mapbox, Bokeh and so on.
In this post, I am showing how I plot my data on maps when doing analysis of data with geographic information using Plotly.
For this demonstration, I am using a house rental price dataset of San Francisco, California. This dataset contains following features to begin with.

After initial cleaning I wanted to get zip code information of the individual houses. I used uszipcode
package to get those information from latitude and longitude data. Additionally pandas and Plotly express is used. Code for this is following:
# data manipulation
import pandas as pd
# data cleaning
import re
import missingno
# Data Visualization
import plotly.express as px
I used this to group data by zip codes to get average rental price per zip code, and visualize on a map. This is the end result.

Code:
This approach utilizes geojason file that contains zip code boundaries of zip codes in the USA. Those are courtesy of OpenDataDE, files can be found here. To get those information useful for using in Plotly, this line is used.
for feature in zipcode_data['features']:
feature['id'] = feature['properties']['ZCTA5CE10']
More on this from plotly documentation can be found here.
To get the location of each house on a interactive map, I used following code:

More on this from plotly documentation can be found here.
For a static output use this instead of showing the object by using fig.show()
. You can also save this as image by tinkering the output type.
import plotly.io as plyIo
img_bytes = fig.to_image(format="png", width=1200, height=700, scale=1)
from IPython.display import Image
display(Image(img_bytes))
All the workings and files can be found [here](https://github.com/tamjid-ahsan/House-rental-price-prediction) on GitHub. An extension of this project on House price prediction using these data can be found here on Github.
That’s all for today. Until next time!