hhalim's picture
Create app.py
56d2707
raw
history blame
885 Bytes
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"])