awacke1 commited on
Commit
05db34c
·
1 Parent(s): 94a831d

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -0
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Write a streamlit program that demonstrates Data synthesis. Synthesize data from multiple sources to create new datasets. Use two datasets and demonstrate pandas dataframe query merge and join with two datasets in python list dictionaries: 1) List of Hospitals that are over 1000 bed count by city and state, and 2) State population size and square miles. Perform a calculated function on the merged dataset.
2
+
3
+ import streamlit as st
4
+ import pandas as pd
5
+
6
+ # Define the hospital dataset with the top five largest hospitals in the US
7
+ hospitals = [
8
+ {"name": "Mayo Clinic", "city": "Rochester", "state": "MN", "bed_count": 3047, "link": "https://www.mayoclinic.org/"},
9
+ {"name": "Florida Hospital Orlando", "city": "Orlando", "state": "FL", "bed_count": 2218, "link": "https://www.adventhealth.com/hospital/adventhealth-orlando"},
10
+ {"name": "Jackson Memorial Hospital", "city": "Miami", "state": "FL", "bed_count": 1708, "link": "https://jacksonhealth.org/jackson-memorial-hospital/"},
11
+ {"name": "UPMC Presbyterian Shadyside", "city": "Pittsburgh", "state": "PA", "bed_count": 1620, "link": "https://www.upmc.com/locations/hospitals/presbyterian"},
12
+ {"name": "NewYork-Presbyterian Hospital", "city": "New York", "state": "NY", "bed_count": 1565, "link": "https://www.nyp.org/"}
13
+ ]
14
+
15
+ # Define the state population and size dataset with the five states used in the hospital dataset
16
+ states = [
17
+ {"state": "MN", "population": 5706494, "square_miles": 86936, "source": "U.S. Census Bureau"},
18
+ {"state": "FL", "population": 21538187, "square_miles": 65755, "source": "U.S. Census Bureau"},
19
+ {"state": "PA", "population": 13002700, "square_miles": 46054, "source": "U.S. Census Bureau"},
20
+ {"state": "NY", "population": 20201249, "square_miles": 54556, "source": "U.S. Census Bureau"},
21
+ {"state": "CA", "population": 39538223, "square_miles": 163696, "source": "U.S. Census Bureau"}
22
+ ]
23
+
24
+ # Convert the datasets to pandas dataframes
25
+ hospitals_df = pd.DataFrame(hospitals)
26
+ states_df = pd.DataFrame(states)
27
+
28
+ # Merge the two datasets on the "state" column
29
+ merged_df = pd.merge(hospitals_df, states_df, on="state")
30
+
31
+ # Calculate the average hospital bed count per square mile for each state
32
+ merged_df["bed_count_per_square_mile"] = merged_df["bed_count"] / merged_df["square_miles"]
33
+
34
+ # Display the merged and calculated data in a table
35
+ st.write(merged_df)