import streamlit as st import pandas as pd import plotly.express as px # Function to plot the map def plot_map(data): fig = px.choropleth(data, locations='State', locationmode="USA-states", color='Revenue', scope="usa", title="Top Corporations by State in the United States", hover_name='Corporation', hover_data=['Revenue']) return fig # Streamlit app st.title('Top Corporations by State in the United States') # Upload CSV uploaded_files = st.file_uploader("Choose a CSV file", accept_multiple_files=True, type="csv") # Display map button display_map_button = st.button('Display Map of CSV Data 🗺️') # If button is clicked, use uploaded files to generate maps or use the default CSV file if display_map_button: if uploaded_files: for uploaded_file in uploaded_files: data = pd.read_csv(uploaded_file) st.write(f"Map for {uploaded_file.name}") st.plotly_chart(plot_map(data)) else: # Use the default CSV file if no files are uploaded data = pd.read_csv('corporations_data.csv') st.plotly_chart(plot_map(data))