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