首页 > 解决方案 > Pythons 'DataFrame' 对象不可调用 - FOR ERROR

问题描述

早上好,我的 df(df_part3) 在上面:

Postal Code Borough Neighbourhood   Latitude    Longitude
0   M5A Downtown Toronto    Regent Park, Harbourfront   43.654260   -79.360636
1   M7A Downtown Toronto    Queen's Park, Ontario Provincial Government 43.662301   -79.389494
2   M5B Downtown Toronto    Garden District, Ryerson    43.657162   -79.378937
3   M5C Downtown Toronto    St. James Town  43.651494   -79.375418
4   M4E East Toronto    The Beaches 43.676357   -79.293031
... ... ... ... ... ...
34  M5W Downtown Toronto    Stn A PO Boxes  43.646435   -79.374846
35  M4X Downtown Toronto    St. James Town, Cabbagetown 43.667967   -79.367675
36  M5X Downtown Toronto    First Canadian Place, Underground city  43.648429   -79.382280
37  M4Y Downtown Toronto    Church and Wellesley    43.665860   -79.383160
38  M7Y East Toronto    Business reply mail Processing Centre, South C...   43.662744   -79.321558

我的代码在这里:

map_toronto = folium.Map(location=[latitude, longitude], zoom_start=11)

# add markers to map
for lat, lng, label in zip(df_part3['Latitude'], df_part3['Longitude'], df_part3['Neighbourhood']):
    label = folium.Popup(label, parse_html=True)
folium.CircleMarker(
    [lat, lng],
    radius=5,
    popup=label,
    color='blue',
    fill=True,
    fill_color='#3186cc',
    fill_opacity=0.7,
    parse_html=False).add_to(map_toronto)  

map_toronto

但是当我运行它时,我得到:

TypeError: 'DataFrame' 对象不可调用
----> 5 for lat, lng, label in zip(df_part3['Latitude'], df_part3['Longitude'], df_part3['Neighbourhood']):

有谁知道如何帮助我?

标签: pythonfor-loop

解决方案


推荐阅读