Я использую приведенный ниже код для перебора серии почтовых индексов Лондона, и он возвращает ошибку, которую я не смог исправить. Любые идеи - я думаю, что возвращаемые данные не включают имя, но не уверены.
Код
def getNearbyVenues(names, latitudes, longitudes, radius=1000):
venues_list=[]
for name, lat, lng in zip(names, latitudes, longitudes):
print(name)
# create the API request URL
url = 'https://api.foursquare.com/v2/venues/explore?&client_id={}&client_secret={}&v={}&ll={},{}&radius={}&limit={}'.format(
CLIENT_ID,
CLIENT_SECRET,
VERSION,
lat,
lng,
radius,
LIMIT)
# make the GET request
results = requests.get(url).json()['response'].get('groups',[{}])[0].get('items')
# return only relevant information for each nearby venue
venues_list.append([(
name,
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 = ['Name',
'latitude',
'longitude',
'Venue',
'Venue Latitude',
'Venue Longitude',
'Venue Category']
return(nearby_venues)
Ошибка
TypeError Traceback (most recent call last)
<ipython-input-54-110fa1855079> in <module>
1 london_venues = getNearbyVenues(names=df2['Postcode'],
2 latitudes=df2['Latitude'],
----> 3 longitudes=df2['Longitude']
4 )
<ipython-input-52-0754ad0a5b0e> in getNearbyVenues(names, latitudes, longitudes, radius)
25 v['venue']['location']['lat'],
26 v['venue']['location']['lng'],
---> 27 v['venue']['categories'][0]['name']) for v in results])
28
29 nearby_venues = pd.DataFrame([item for venue_list in venues_list for item in venue_list])
TypeError: 'NoneType' object is not iterable