File size: 1,128 Bytes
59ae744
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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

# Define two example datasets
hospitals = [
    {'City': 'New York', 'State': 'NY', 'Beds': 2000},
    {'City': 'Los Angeles', 'State': 'CA', 'Beds': 1500},
    {'City': 'Chicago', 'State': 'IL', 'Beds': 1200},
    {'City': 'Houston', 'State': 'TX', 'Beds': 1800},
    {'City': 'Phoenix', 'State': 'AZ', 'Beds': 1300}
]

populations = [
    {'State': 'NY', 'Population': 19530000, 'SquareMiles': 54555},
    {'State': 'CA', 'Population': 39540000, 'SquareMiles': 163696},
    {'State': 'IL', 'Population': 12670000, 'SquareMiles': 57914},
    {'State': 'TX', 'Population': 29150000, 'SquareMiles': 268596},
    {'State': 'AZ', 'Population': 7279000, 'SquareMiles': 113990}
]

# Merge the datasets based on the state column
df = pd.merge(pd.DataFrame(hospitals), pd.DataFrame(populations), on='State')

# Filter the merged dataset to include only hospitals with over 1000 beds
df = df[df['Beds'] > 1000]

# Calculate the number of beds per square mile for each state
df['BedsPerSquareMile'] = df['Beds'] / df['SquareMiles']

# Display the resulting dataframe in Streamlit
st.write(df)