abdouramandalil commited on
Commit
ca7f38e
1 Parent(s): 47576fd

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -0
app.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import numpy as np
3
+ import pandas as pd
4
+ import plotly.express as px
5
+
6
+ st.set_page_config(layout='wide')
7
+
8
+ df = pd.read_csv('india.csv')
9
+
10
+ list_of_states = list(df['State'].unique())
11
+ list_of_states.insert(0,'Overall India')
12
+
13
+ st.sidebar.title('India Ka Data Viz')
14
+
15
+ selected_state = st.sidebar.selectbox('Select a state',list_of_states)
16
+ primary = st.sidebar.selectbox('Select Primary Parameter',sorted(df.columns[5:]))
17
+ secondary = st.sidebar.selectbox('Select Secondary Parameter',sorted(df.columns[5:]))
18
+
19
+ plot = st.sidebar.button('Plot Graph')
20
+
21
+ if plot:
22
+
23
+ st.text('Size represent primary parameter')
24
+ st.text('Color represents secondary parameter')
25
+ if selected_state == 'Overall India':
26
+ # plot for india
27
+ fig = px.scatter_mapbox(df, lat="Latitude", lon="Longitude", size=primary, color=secondary, zoom=4,size_max=35,
28
+ mapbox_style="carto-positron",width=1200,height=700,hover_name='District')
29
+
30
+ st.plotly_chart(fig,use_container_width=True)
31
+ else:
32
+ # plot for state
33
+ state_df = df[df['State'] == selected_state]
34
+
35
+ fig = px.scatter_mapbox(state_df, lat="Latitude", lon="Longitude", size=primary, color=secondary, zoom=6, size_max=35,
36
+ mapbox_style="carto-positron", width=1200, height=700,hover_name='District')
37
+
38
+ st.plotly_chart(fig, use_container_width=True)
39
+
40
+
41
+