Map-app / app.py
Jasonntone's picture
Create app.py
1da4aa0 verified
raw
history blame contribute delete
No virus
1.54 kB
import streamlit as st
import numpy as np
import pandas as pd
import seaborn as sn
import matplotlib.pyplot as plt
import plotly.express as px
st.set_option('deprecation.showPyplotGlobalUse', False)
st.set_page_config(layout='wide')
df = pd.read_csv('india.csv')
list_of_states = list(df['State'].unique())
list_of_states.insert(0, 'Overall India')
selected_state = st.sidebar.selectbox('Select a state', list_of_states)
primary = st.sidebar.selectbox('Select Primary Parameter',
sorted(df.columns[5:]))
secondary = st.sidebar.selectbox('Select Secondary Parameter',
sorted(df.columns[5:]))
plot = st.sidebar.button('Plot Graph')
if plot:
st.text('Size represents Primary Parameter')
st.text('Color represents Secondary Parameter')
if selected_state == 'Overall India':
fig = px.scatter_mapbox(df,lat='Latitude',lon='Longitude',
size=primary,color=secondary,zoom=4,size_max=35,
mapbox_style='carto-positron', width=1200,height=700,hover_name='District')
st.plotly_chart(fig,use_container_width=True)
else:
state_df = df[df.State == selected_state]
fig = px.scatter_mapbox(state_df,lat='Latitude',lon='Longitude',
size=primary,color=secondary,zoom=6,size_max=35,
mapbox_style='carto-positron', width=1200,height=700,hover_name='District')
st.plotly_chart(fig,use_container_width=True)