我正在尝试使用Foursquare API获取附近的场地时遇到此关键错误:'组'

问题描述 投票:0回答:1

[嗨,我尝试使用Foursquare API获取附近的场地时得到keyerror: 'groups'。以下是我的代码:

LIMIT = 100 # limit of number of venues returned by Foursquare API


radius = 500 # define radius

venues_list = []

for lat, long, post, borough, neighborhood, hospital in zip(hospital_df['Latitude'], hospital_df['Longitude'], hospital_df['Pincode'], hospital_df['District'], hospital_df['Location'], hospital_df['Hospital_Name']):
    print(neighborhood)
    print(borough)
    url = "https://api.foursquare.com/v2/venues/explore?client_id={}&client_secret={}&v= 
    {}&ll={},{}&radius={}&limit={}".format(
        CLIENT_ID,
        CLIENT_SECRET,
        VERSION,
        lat,
        long,
        radius, 
        LIMIT)
    results = requests.get(url).json()["response"]['groups'][0]['items']
    venues_list.append([(
            post, 
            borough,
            neighborhood,
            hospital,
            lat, 
            lng, 
            v['venue']['name'], 
            v['venue']['location']['lat'], 
            v['venue']['location']['lng'],  
            v['venue']['categories'][0]['name']) for v in results])

nearby_venues = pd.DataFrame([item for venue_list in venues_list for item in venue_list])
nearby_venues.columns = ['PostalCode', 'Borough', 'Neighborhood', 'Hospital', 'Neighborhood_Latitude', 'Neighborhood_Longitude', 'VenueName', 'VenueLatitude', 'VenueLongitude', 'VenueCategory']

我不断收到以下错误:

KeyError:'组'

foursquare
1个回答
0
投票

尝试从Foursquare帐户重置您的CLIENT SECRET。它对我有用。

© www.soinside.com 2019 - 2024. All rights reserved.