Reputation: 13
I'm trying to build a loop that iterates and places the variables lat and lng into , "target_coordinates". How do I format this correctly with two variables?
lat=hotel_df["Lat"]
lng=hotel_df["Lng"]
for i,j in lat,lng:
target_coordinates = "{lat},{lng}"
target_search = "Hotel"
target_radius = 5000
I either get the error above or: TypeError: 'Series' object cannot be interpreted as an integer
Upvotes: 0
Views: 444
Reputation: 148900
You could use zip
and values
:
...
for i,j in zip(lat.values, lng.values):
...
Upvotes: 1
Reputation: 7625
You are putting a pandas.Series
to string, which is wrong and produces an error. To solve it, try to use this code:
for i, row in hotel_df.iterrows():
lat, lng = row['Lat'], row['Lng']
target_coordinates = f"{lat},{lng}"
target_search = "Hotel"
target_radius = 5000
Upvotes: 1