import pandas as pd import streamlit as st import numpy as np import matplotlib.pyplot as plt import seaborn as sns import plotly.express as px st.set_page_config(layout='wide') df = pd.read_csv("india.csv") st.write(df) list_of_states = list(df['State'].unique()) # ressort la liste des stade disponible list_of_states.insert(0,'Overall India') selected_state = st.sidebar.selectbox('select a state',list_of_states) primary = st.sidebar.selectbox('selected a primary parameter',sorted(df.columns[5:])) secondary = st.sidebar.selectbox('select a secondary parameter',sorted(df.columns[5:])) plot = st.sidebar.button('Plot graph')# creation du bouton dans le sidebar if plot: st.text('Size represent primary parameters') st.text('Colors represent secondary parameters') if selected_state == 'Overall India' : # plot for india country 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: # plot for state 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) # afficher le mapbox