Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
|
| 4 |
+
# Dataset 1: List of Hospitals that are over 1000 bed count by city and state
|
| 5 |
+
hospitals = [
|
| 6 |
+
{'City': 'New York', 'State': 'NY', 'Hospital Name': 'New York-Presbyterian Hospital', 'Bed Count': 2446},
|
| 7 |
+
{'City': 'Houston', 'State': 'TX', 'Hospital Name': 'Memorial Hermann-Texas Medical Center', 'Bed Count': 2048},
|
| 8 |
+
{'City': 'Philadelphia', 'State': 'PA', 'Hospital Name': 'Hospital of the University of Pennsylvania', 'Bed Count': 1875},
|
| 9 |
+
{'City': 'Los Angeles', 'State': 'CA', 'Hospital Name': 'Cedars-Sinai Medical Center', 'Bed Count': 1434},
|
| 10 |
+
{'City': 'Boston', 'State': 'MA', 'Hospital Name': 'Massachusetts General Hospital', 'Bed Count': 1051},
|
| 11 |
+
]
|
| 12 |
+
|
| 13 |
+
# Dataset 2: State population size and square miles
|
| 14 |
+
population = [
|
| 15 |
+
{'State': 'CA', 'Population': 39538223, 'Square Miles': 163696},
|
| 16 |
+
{'State': 'TX', 'Population': 29145505, 'Square Miles': 268596},
|
| 17 |
+
{'State': 'NY', 'Population': 20215751, 'Square Miles': 54555},
|
| 18 |
+
{'State': 'FL', 'Population': 21538187, 'Square Miles': 65755},
|
| 19 |
+
{'State': 'PA', 'Population': 13002700, 'Square Miles': 46054},
|
| 20 |
+
]
|
| 21 |
+
|
| 22 |
+
# Convert the dictionaries into pandas dataframes
|
| 23 |
+
hospitals_df = pd.DataFrame(hospitals)
|
| 24 |
+
population_df = pd.DataFrame(population)
|
| 25 |
+
|
| 26 |
+
# Merge the two dataframes using 'State' as the key
|
| 27 |
+
merged_df = pd.merge(hospitals_df, population_df, on='State')
|
| 28 |
+
|
| 29 |
+
# Join the 'City' and 'State' columns into a single column
|
| 30 |
+
merged_df['City_State'] = merged_df['City'] + ', ' + merged_df['State']
|
| 31 |
+
|
| 32 |
+
# Calculate the number of hospital beds per 10,000 people in each city-state
|
| 33 |
+
merged_df['Beds per 10K People'] = (merged_df['Bed Count'] / merged_df['Population']) * 10000
|
| 34 |
+
|
| 35 |
+
# Display the final merged dataframe
|
| 36 |
+
st.write(merged_df)
|