Spaces:
Sleeping
Sleeping
Create backup.app.py
Browse files- backup.app.py +31 -0
backup.app.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
import plotly.express as px
|
4 |
+
|
5 |
+
# Function to plot the map
|
6 |
+
def plot_map(data):
|
7 |
+
fig = px.choropleth(data, locations='State', locationmode="USA-states", color='Revenue',
|
8 |
+
scope="usa", title="Top Corporations by State in the United States",
|
9 |
+
hover_name='Corporation', hover_data=['Revenue'])
|
10 |
+
return fig
|
11 |
+
|
12 |
+
# Streamlit app
|
13 |
+
st.title('Top Corporations by State in the United States')
|
14 |
+
|
15 |
+
# Upload CSV
|
16 |
+
uploaded_files = st.file_uploader("Choose a CSV file", accept_multiple_files=True, type="csv")
|
17 |
+
|
18 |
+
# Display map button
|
19 |
+
display_map_button = st.button('Display Map of CSV Data 🗺️')
|
20 |
+
|
21 |
+
# If button is clicked, use uploaded files to generate maps or use the default CSV file
|
22 |
+
if display_map_button:
|
23 |
+
if uploaded_files:
|
24 |
+
for uploaded_file in uploaded_files:
|
25 |
+
data = pd.read_csv(uploaded_file)
|
26 |
+
st.write(f"Map for {uploaded_file.name}")
|
27 |
+
st.plotly_chart(plot_map(data))
|
28 |
+
else:
|
29 |
+
# Use the default CSV file if no files are uploaded
|
30 |
+
data = pd.read_csv('corporations_data.csv')
|
31 |
+
st.plotly_chart(plot_map(data))
|