Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
|
4 |
+
# Define datasets
|
5 |
+
hospital_data = [
|
6 |
+
{'city': 'New York', 'state': 'NY', 'bed_count': 1500},
|
7 |
+
{'city': 'Los Angeles', 'state': 'CA', 'bed_count': 2000},
|
8 |
+
{'city': 'Chicago', 'state': 'IL', 'bed_count': 1200},
|
9 |
+
{'city': 'Houston', 'state': 'TX', 'bed_count': 1300},
|
10 |
+
{'city': 'Philadelphia', 'state': 'PA', 'bed_count': 1100}
|
11 |
+
]
|
12 |
+
|
13 |
+
population_data = [
|
14 |
+
{'state': 'NY', 'population': 20000000, 'square_miles': 54555},
|
15 |
+
{'state': 'CA', 'population': 40000000, 'square_miles': 163696},
|
16 |
+
{'state': 'IL', 'population': 13000000, 'square_miles': 57914},
|
17 |
+
{'state': 'TX', 'population': 29000000, 'square_miles': 268596},
|
18 |
+
{'state': 'PA', 'population': 13000000, 'square_miles': 46055}
|
19 |
+
]
|
20 |
+
|
21 |
+
# Convert datasets to pandas dataframes
|
22 |
+
hospital_df = pd.DataFrame(hospital_data)
|
23 |
+
population_df = pd.DataFrame(population_data)
|
24 |
+
|
25 |
+
# Merge datasets on 'state' column
|
26 |
+
merged_df = pd.merge(hospital_df, population_df, on='state')
|
27 |
+
|
28 |
+
# Filter merged dataset to only include hospitals with over 1000 beds
|
29 |
+
filtered_df = merged_df[merged_df['bed_count'] > 1000]
|
30 |
+
|
31 |
+
# Calculate hospital density as population per hospital bed
|
32 |
+
filtered_df['hospital_density'] = filtered_df['population'] / filtered_df['bed_count']
|
33 |
+
|
34 |
+
# Display merged and filtered dataset in Streamlit app
|
35 |
+
st.write(filtered_df)
|