import streamlit as st import pandas as pd # Dataset 1: List of Hospitals that are over 1000 bed count by city and state hospitals = [ {'City': 'New York', 'State': 'NY', 'Hospital Name': 'New York-Presbyterian Hospital', 'Bed Count': 2446}, {'City': 'Houston', 'State': 'TX', 'Hospital Name': 'Memorial Hermann-Texas Medical Center', 'Bed Count': 2048}, {'City': 'Philadelphia', 'State': 'PA', 'Hospital Name': 'Hospital of the University of Pennsylvania', 'Bed Count': 1875}, {'City': 'Los Angeles', 'State': 'CA', 'Hospital Name': 'Cedars-Sinai Medical Center', 'Bed Count': 1434}, {'City': 'Boston', 'State': 'MA', 'Hospital Name': 'Massachusetts General Hospital', 'Bed Count': 1051}, ] # Dataset 2: State population size and square miles population = [ {'State': 'CA', 'Population': 39538223, 'Square Miles': 163696}, {'State': 'TX', 'Population': 29145505, 'Square Miles': 268596}, {'State': 'NY', 'Population': 20215751, 'Square Miles': 54555}, {'State': 'FL', 'Population': 21538187, 'Square Miles': 65755}, {'State': 'PA', 'Population': 13002700, 'Square Miles': 46054}, ] # Convert the dictionaries into pandas dataframes hospitals_df = pd.DataFrame(hospitals) population_df = pd.DataFrame(population) # Merge the two dataframes using 'State' as the key merged_df = pd.merge(hospitals_df, population_df, on='State') # Join the 'City' and 'State' columns into a single column merged_df['City_State'] = merged_df['City'] + ', ' + merged_df['State'] # Calculate the number of hospital beds per 10,000 people in each city-state merged_df['Beds per 10K People'] = (merged_df['Bed Count'] / merged_df['Population']) * 10000 # Display the final merged dataframe st.write(merged_df)