File size: 885 Bytes
56d2707
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import streamlit as st 

import pandas as pd
import numpy as np

# Create two datasets
hospitals_list = [{"City":"New York","State": "NY","Bed Count":1200},{"City":"Los Angeles","State":"CA","Bed Count":1400},{"City":"Chicago","State":"IL","Bed Count":1650}]

state_data = [{"State":"NY","Population": 8.5e6,"Square Miles": 54.556},{"State":"CA","Population": 39.25e6,"Square Miles": 163.696},{"State":"IL","Population": 12.8e6,"Square Miles": 57.914}]

# Create dataframes from the datasets
hospitals_df = pd.DataFrame(hospitals_list)
state_df = pd.DataFrame(state_data)

# Merge the two datasets together
merged_df = pd.merge(hospitals_df, state_df, on="State")

# Display the merged dataset
st.write("Merged Dataset")
st.write(merged_df)

# Calculate average beds per square mile
st.write("Calculated Function")
st.write(merged_df.loc[:,"Bed Count"]/merged_df.loc[:,"Square Miles"])