awacke1 commited on
Commit
7c7364a
·
1 Parent(s): da60afc

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +55 -0
app.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+
4
+
5
+ def generate_hospital_data():
6
+ # Generate hospital data
7
+ hospitals = {
8
+ "city": ["New York", "Los Angeles", "Chicago", "Houston", "Phoenix"],
9
+ "state": ["NY", "CA", "IL", "TX", "AZ"],
10
+ "bed_count": [1200, 1500, 1100, 1300, 1400],
11
+ }
12
+ df = pd.DataFrame(hospitals)
13
+ return df
14
+
15
+
16
+ def generate_state_data():
17
+ # Generate state data
18
+ states = {
19
+ "state": ["NY", "CA", "IL", "TX", "AZ"],
20
+ "population": [20000000, 40000000, 13000000, 29000000, 7000000],
21
+ "square_miles": [54556, 163696, 57914, 268596, 113990],
22
+ }
23
+ df = pd.DataFrame(states)
24
+ return df
25
+
26
+
27
+ def merge_datasets(hospitals_df, states_df):
28
+ # Merge hospital and state data
29
+ merged_df = pd.merge(hospitals_df, states_df, on="state")
30
+ return merged_df
31
+
32
+
33
+ def calculate_beds_per_capita(merged_df):
34
+ # Calculate beds per capita
35
+ merged_df["beds_per_capita"] = merged_df["bed_count"] / merged_df["population"]
36
+ return merged_df
37
+
38
+
39
+ def main():
40
+ # Generate data
41
+ hospitals_df = generate_hospital_data()
42
+ states_df = generate_state_data()
43
+
44
+ # Merge datasets
45
+ merged_df = merge_datasets(hospitals_df, states_df)
46
+
47
+ # Calculate beds per capita
48
+ merged_df = calculate_beds_per_capita(merged_df)
49
+
50
+ # Show merged and calculated data
51
+ st.write(merged_df)
52
+
53
+
54
+ if __name__ == "__main__":
55
+ main()