Spaces:
Sleeping
Sleeping
File size: 1,165 Bytes
f542e7e 017ce74 dab3650 f542e7e 017ce74 0631b4d 081bf5b 0631b4d 081bf5b 017ce74 |
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 32 |
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(locations=data['State'], locationmode="USA-states", color=data['Revenue'],
scope="usa", title="Top Corporations by State in the United States",
hover_name=data['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))
|