File size: 1,359 Bytes
8b8ab1a
 
 
 
 
 
 
 
 
77a3835
8b8ab1a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import streamlit as st
import numpy as np
import pandas as pd
import plotly.express as px

st.set_page_config(layout="wide")

df = pd.read_csv("geospatial_data.csv")

st.title("India Census")
st.sidebar.title("Census Data")

list_of_states = list(df["State"].unique())
list_of_states.insert(0,"Overall States")

select_state = st.sidebar.selectbox("Select State",list_of_states)
primary_params = st.sidebar.selectbox("Select Primary Parameter",sorted(df.columns[5:]))
secondary_params = 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 select_state == "Overall States":
        fig = px.scatter_mapbox(df,"Latitude","Longitude",zoom=4,mapbox_style="carto-positron",size=primary_params,color=secondary_params,size_max=35,width=1200,height=700,hover_name="District")
        st.plotly_chart(fig,use_container_width=True)
    else:
        # plotting for particular state
        state_df = df[df["State"] == select_state]
        fig = px.scatter_mapbox(state_df,"Latitude","Longitude",zoom=3,mapbox_style="carto-positron",size=primary_params,color=secondary_params,size_max=35,width=1200,height=700,hover_name="District")
        st.plotly_chart(fig,use_container_width=True)