File size: 1,328 Bytes
ab955e7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
33
34
35
36
import streamlit as st
import pandas as pd

# Define datasets
hospital_data = [
    {'city': 'New York', 'state': 'NY', 'bed_count': 1500},
    {'city': 'Los Angeles', 'state': 'CA', 'bed_count': 2000},
    {'city': 'Chicago', 'state': 'IL', 'bed_count': 1200},
    {'city': 'Houston', 'state': 'TX', 'bed_count': 1300},
    {'city': 'Philadelphia', 'state': 'PA', 'bed_count': 1100}
]

population_data = [
    {'state': 'NY', 'population': 20000000, 'square_miles': 54555},
    {'state': 'CA', 'population': 40000000, 'square_miles': 163696},
    {'state': 'IL', 'population': 13000000, 'square_miles': 57914},
    {'state': 'TX', 'population': 29000000, 'square_miles': 268596},
    {'state': 'PA', 'population': 13000000, 'square_miles': 46055}
]

# Convert datasets to pandas dataframes
hospital_df = pd.DataFrame(hospital_data)
population_df = pd.DataFrame(population_data)

# Merge datasets on 'state' column
merged_df = pd.merge(hospital_df, population_df, on='state')

# Filter merged dataset to only include hospitals with over 1000 beds
filtered_df = merged_df[merged_df['bed_count'] > 1000]

# Calculate hospital density as population per hospital bed
filtered_df['hospital_density'] = filtered_df['population'] / filtered_df['bed_count']

# Display merged and filtered dataset in Streamlit app
st.write(filtered_df)