I have the following loop:
max_potential = 100
for indx, values in geography.sort_values(district)[neighborhood].items():
population = geography_clusters[geography_clusters['neighborhood']==indx]['potential'].astype(int)
potential_neighborhood = potential_neighborhood + population
if potential_neighborhood < max_potential:
list_close_neighborhood.append(indx)
And I get the following error
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
on this part of the code:
if potential_neighborhood < max_potential:
I believe that as the input is a series, I can't make a conditional based on the whole series. What I want to do is mainly save the value of each neighborhood (that works as an index in the loop) if that row satisfies the following condition:
if potential_neighborhood < max_potential:
And append the [neighborhood] value on a list [list_close_neighborhood]. Is it possible?