VizLib-PyDeck / app.py
awacke1's picture
Update app.py
d4ac004
raw
history blame
5.03 kB
import pandas as pd
import pydeck as pdk
# Define the list of dictionaries with hospital information
hospital_list = [
{
'bed_count': 2766,
'name': 'New York-Presbyterian Hospital',
'city': 'New York',
'state': 'NY',
'latitude': 40.8404,
'longitude': -73.9508,
'zip': '10032'
},
{
'bed_count': 2145,
'name': 'Florida Hospital Orlando',
'city': 'Orlando',
'state': 'FL',
'latitude': 28.5536,
'longitude': -81.3568,
'zip': '32803'
},
{
'bed_count': 2020,
'name': 'Jackson Memorial Hospital',
'city': 'Miami',
'state': 'FL',
'latitude': 25.7893,
'longitude': -80.2124,
'zip': '33136'
},
{
'bed_count': 1997,
'name': 'Keck Medical Center of USC',
'city': 'Los Angeles',
'state': 'CA',
'latitude': 34.0522,
'longitude': -118.2437,
'zip': '90033'
},
{
'bed_count': 1956,
'name': 'Montefiore Medical Center',
'city': 'Bronx',
'state': 'NY',
'latitude': 40.8471,
'longitude': -73.8816,
'zip': '10467'
},
{
'bed_count': 1926,
'name': 'Rush University Medical Center',
'city': 'Chicago',
'state': 'IL',
'latitude': 41.8745,
'longitude': -87.6676,
'zip': '60612'
},
{
'bed_count': 1918,
'name': 'University of Michigan Hospitals-Michigan Medicine',
'city': 'Ann Arbor',
'state': 'MI',
'latitude': 42.2814,
'longitude': -83.7483,
'zip': '48109'
},
{
'bed_count': 1863,
'name': 'Parkland Health and Hospital System',
'city': 'Dallas',
'state': 'TX',
'latitude': 32.7767,
'longitude': -96.7970,
'zip': '75235'
},
{
'bed_count': 1858,
'name': 'Houston Methodist Hospital',
'city': 'Houston',
'state': 'TX',
'latitude': 29.7181,
'longitude': -95.4044,
'zip': '77030'
},
{
'bed_count': 1800,
'name': 'Brigham and Women\'s Hospital',
'city': 'Boston',
'state': 'MA',
'latitude': 42.3367,
'longitude': -71.1075,
'zip': '02115'
},
{
'bed_count': 1771,
'name': 'Cleveland Clinic',
'city': 'Cleveland',
'state': 'OH',
'latitude': 41.5047, 'longitude': -81.6218,
'zip': '44195'
},
{
'bed_count': 1730,
'name': 'The Mount Sinai Hospital',
'city': 'New York',
'state': 'NY',
'latitude': 40.7909,
'longitude': -73.9524,
'zip': '10029'
},
{
'bed_count': 1729,
'name': 'Northwestern Memorial Hospital',
'city': 'Chicago',
'state': 'IL',
'latitude': 41.8953,
'longitude': -87.6251,
'zip': '60611'
},
{
'bed_count': 1660,
'name': 'Hospitals of the University of Pennsylvania-Penn Presbyterian',
'city': 'Philadelphia',
'state': 'PA',
'latitude': 39.9526,
'longitude': -75.1652,
'zip': '19104'
},
{
'bed_count': 1642,
'name': 'Johns Hopkins Hospital',
'city': 'Baltimore',
'state': 'MD',
'latitude': 39.2967,
'longitude': -76.5913,
'zip': '21287'
},
{
'bed_count': 1614,
'name': 'Cedars-Sinai Medical Center',
'city': 'Los Angeles',
'state': 'CA',
'latitude': 34.0762,
'longitude': -118.3882,
'zip': '90048'
},
{
'bed_count': 1577,
'name': 'Massachusetts General Hospital',
'city': 'Boston',
'state': 'MA',
'latitude': 42.3639,
'longitude': -71.0711,
'zip': '02114'
},
{
'bed_count': 1566,
'name': 'NYU Langone Hospitals',
'city': 'New York',
'state': 'NY',
'latitude': 40.7429,
'longitude': -73.9750,
'zip': '10016'
},
{
'bed_count': 1547,
'name': 'Mayo Clinic Hospital-Rochester',
'city': 'Rochester',
'state': 'MN',
'latitude': 44.0121,
'longitude': -92.4802,
'zip': '55902'
},
{
'bed_count': 1537,
'name': 'Stanford Health Care-Stanford Hospital',
'city': 'Stanford',
'state': 'CA',
'latitude': 37.4354,
'longitude': -122.1777,
'zip': '94305'
}
]
df = pd.DataFrame(hospital_list)
layer = pdk.Layer(
'ScatterplotLayer',
data=df,
get_position='[longitude, latitude]',
get_radius='bed_count/10',
get_fill_color='[bed_count, 0, 255-bed_count]',
get_line_color=[255, 255, 255],
pickable=True
)
tooltip = {
'html': '<b>{name}</b><br/>{bed_count} beds<br/>{city}, {state} {zip}',
'style': {
'backgroundColor': 'white',
'color': 'black'
}
}
map = pdk.Deck(
map_style='mapbox://styles/mapbox/light-v9',
initial_view_state=pdk.ViewState(
latitude=37.0902,
longitude=-95.7129,
zoom=3,
pitch=0
),
layers=[layer],
tooltip=tooltip
)
map.show()