I am using geoprapy to to get locations via a URL. I have a URL column for my DataFrame. I am attempting to run a pre-built Geograpy function on each URL and create a new column of the locations on the DataFrame. So, I have tried (from other questions):
hits['place'] = geograpy.get_place_context(url=hits.urls)
# and
hits['place'] = hits.apply(geograpy.get_place_context(url=hits.urls), axis=1))
# and
def getPlace(frame):
urls = frame['urls']
print(urls)
frame['place'] = geograpy.get_place_context(url=urls)
return frame
getPlace(hits)
Along with a few others. I keep getting
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
Which I understand as that it is seeing URLs as a whole column and cannot run the function on the column? Doesn't really matter.
How can I run a function for every row in a dataframe and create a new column?
I expect my places to be a 'memory type object' I can reference later. I have part of this to work via:
for url in urls:
place = (geograpy.get_place_context(url=url))
region = place.country_regions
However, later in the code, the iterations causes it to fall apart.