Spaces:
Sleeping
Sleeping
File size: 1,152 Bytes
8a7220f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
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)) |