Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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',page_title='Titre Principale')
|
| 7 |
+
df = pd.read_csv('india.csv')
|
| 8 |
+
|
| 9 |
+
list_of_states = list(df['State'].unique())
|
| 10 |
+
list_of_states.insert(0,'Overall India')
|
| 11 |
+
|
| 12 |
+
st.sidebar.title('india Data Vix')
|
| 13 |
+
selected_state = st.sidebar.selectbox('select a state', list_of_states)
|
| 14 |
+
primary = st.sidebar.selectbox('Select primary Parameter:', sorted(df.columns[5:]))
|
| 15 |
+
secondary = st.sidebar.selectbox('select secondary Parameter:', sorted(df.columns[5:]))
|
| 16 |
+
|
| 17 |
+
plot = st.sidebar.button('Plot a graph')
|
| 18 |
+
if plot:
|
| 19 |
+
st.text('Size represent primary parameter')
|
| 20 |
+
st.text('Color represent secondary parameter')
|
| 21 |
+
if selected_state == 'Overall India':
|
| 22 |
+
#plot for india card
|
| 23 |
+
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")
|
| 24 |
+
st.plotly_chart(fig,use_container_width=True)
|
| 25 |
+
else:
|
| 26 |
+
#plot for a state
|
| 27 |
+
state_df = df[df.State == selected_state]
|
| 28 |
+
fig = px.scatter_mapbox(state_df, lat="Latitude",lon="Longitude",size=primary,
|
| 29 |
+
color=secondary,zoom=4, size_max=35,mapbox_style="carto-positron",
|
| 30 |
+
width=1200, height=700, hover_name="District")
|
| 31 |
+
st.plotly_chart(fig, use_container_width=True)
|