Diff of /clinicalmapfixed.py [000000] .. [6e0d8e]

Switch to unified view

a b/clinicalmapfixed.py
1
from pyzipcode import ZipCodeDatabase
2
import folium
3
import pandas as pd
4
5
clin_addresses = pd.read_excel("/Users/shania/PycharmProjects/ClinicalAttritionRateMap/project_testCleanedUSZip.xlsx")
6
7
zcdb = ZipCodeDatabase()
8
center_map = folium.Map(location=[39.8283, -98.5795], zoom_start=4)
9
10
for index in clin_addresses.index:
11
    zip_code = str(clin_addresses.loc[index, 'zip'])
12
13
    # Remove the extended part from the ZIP code if it exists
14
    if '-' in zip_code:
15
        zip_code = zip_code.split('-')[0]
16
17
    location_name = clin_addresses.loc[index, 'location_name']
18
    nct_id = clin_addresses.loc[index, 'nct_id']
19
    dropout_rate = clin_addresses.loc[index, 'dropout_percentage_all']
20
    phase = clin_addresses.loc[index, 'phase']
21
    study_type = clin_addresses.loc[index, 'study_type']
22
23
    try:
24
        location = zcdb[zip_code]
25
        lon, lat = location.longitude, location.latitude
26
        coordinates = [lat, lon]
27
28
        folium.Marker(
29
            location=coordinates,
30
            popup=f"{location_name}\nNCT ID: {nct_id}\nDropout Rate: {dropout_rate}\nPhase: {phase}\nStudy Type: {study_type}"
31
        ).add_to(center_map)
32
    except KeyError:
33
        print(f"Couldn't find location for ZIP code: {zip_code}")
34
35
# Save the map to an HTML file
36
center_map.save('map-clinical_trials.html')