Spaces:
Build error
Build error
File size: 5,092 Bytes
ba0998d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
import streamlit as st
st.markdown("""
π Welcome to my guide on creating a streamlit application for tracking health care problems and conditions! π¨ββοΈπ©ββοΈ
π Here's a step by step outline to get you started:
Step 1: Install Streamlit π₯
First things first, let's make sure we have Streamlit installed! Here's how:
add a requirements.txt file with each library you will need including:
streamlit
pandas
geopy
folium
Step 2: Create a new file π
Now that Streamlit is installed, let's create a new Python file for our application.
Here's how:
Create a new app.py file.
Step 3: Import the necessary libraries π
The requirements.txt will be executed with pip install -r requirements.txt
This will import the following libraries:
streamlit (for building the app)
pandas (for working with data)
geopy (for geocoding and distance calculations)
folium (for creating maps)
Step 4: Create the user interface π₯οΈ
Now let's create the user interface for our app! Here's how:
Use the streamlit library to create a title for the app
Create an input field for the user to enter their location
Create checkboxes for the health care problems and conditions the user is interested in
Use the streamlit library to create a button to submit the user's input
Step 5: Retrieve and filter data π
Now that we have the user's input, let's retrieve and filter the data we need. Here's how:
Use the pandas library to read in a dataset of health care providers and facilities in the area
Use the geopy library to geocode the user's location
Calculate the distance between the user's location and each provider/facility in the dataset
Filter the dataset based on the user's selected health care problems/conditions
Step 6: Display the results π
Finally, let's display the results to the user! Here's how:
Use the folium library to create a map with markers for each provider/facility in the filtered dataset
Display the map to the user
Use the streamlit library to display a table with information about each provider/facility in the filtered dataset
π And that's it! You now have a streamlit application for tracking health care problems and conditions and identifying providers and facilities in the user's area. Good luck building your app! π
""")
import streamlit as st
import pandas as pd
from geopy.geocoders import Nominatim
import folium
# Set page title
st.set_page_config(page_title="Healthcare Providers Map")
# Define function to get geolocation data from user's input
def get_location(address):
geolocator = Nominatim(user_agent="my_app")
location = geolocator.geocode(address)
return (location.latitude, location.longitude)
# Define function to filter providers by selected health conditions
def filter_providers(df, conditions):
return df[df['Conditions'].apply(lambda x: any(item for item in conditions if item in x))]
# Load data
#df = pd.read_csv('healthcare_providers.csv')
df = pd.read_csv('minnesota_providers.csv')
# Create UI elements
st.title("Healthcare Providers Map")
location_input = st.text_input("Enter your address to find healthcare providers in your area:")
conditions_checkboxes = st.sidebar.multiselect("Select the health conditions you are interested in:",
['Asthma', 'Cancer', 'Diabetes', 'Heart disease', 'High blood pressure'])
if st.button("Find Providers"):
# Get user's location
user_location = get_location(location_input)
# Filter providers based on selected conditions
filtered_providers = filter_providers(df, conditions_checkboxes)
# Create map with markers for each provider
m = folium.Map(location=user_location, zoom_start=12)
for index, row in filtered_providers.iterrows():
folium.Marker([row['Latitude'], row['Longitude']], popup=row['Name']).add_to(m)
# Display map to user
folium_static(m)
import pandas as pd
# Define column names for the providers
columns = ['Name', 'Address', 'City', 'State', 'Zipcode', 'Phone', 'Website']
# Define the list of providers as a list of lists
providers = [
['Minnesota Community Care', '570 University Avenue', 'Saint Paul', 'MN', '55103', '(651) 602-7500', 'https://mncc.org/'],
['Hennepin Healthcare', '701 Park Avenue', 'Minneapolis', 'MN', '55415', '(612) 873-3000', 'https://www.hennepinhealthcare.org/'],
['Allina Health', '800 East 28th Street', 'Minneapolis', 'MN', '55407', '(612) 863-4000', 'https://www.allinahealth.org/'],
['Fairview Health Services', '2450 Riverside Avenue', 'Minneapolis', 'MN', '55454', '(612) 672-7000', 'https://www.fairview.org/'],
['HealthPartners', '8170 33rd Avenue South', 'Bloomington', 'MN', '55425', '(952) 883-6000', 'https://www.healthpartners.com/'],
['Mayo Clinic Health System', '1216 Second Street Southwest', 'Rochester', 'MN', '55902', '(507) 266-7890', 'https://www.mayoclinic.org/'],
]
# Create a DataFrame from the providers list
df = pd.DataFrame(providers, columns=columns)
# Save the DataFrame as a CSV file
df.to_csv('minnesota_providers.csv', index=False)
|