I have a database with, consumption and coordinates, such:
I need to write a code that allows me to find, from local to local, consumptions that are less than average consumption within that radius of 100m. It is intended that the radius of 100m be calculated not once, but for each pair of coordinates.
code:
R9 = []
R9_NaN = []
for index, row in df.iterrows():
coord_1 = (row['X'], row['Y'])
for index, row2 in df.iterrows():
coord_2 = (row['X'], row['Y'])
if coord_2 != coord_1:
dist = geopy.distance.geodesic(coord_1, coord_2).km
if dist <= 0.100:
média=sum((row['Consumo2018']/12)/(len(coord_2)+1))
if row['Consumo2018']/12 < 1.5*média:
R9_NaN.append(index)
R9.append(0)
else:
R9.append(0)
print(R9)
Geopy.distance is a library that already calculates the distance between two coordinates.
In the above code; "média" is assumed to be an average consumption of sites within the 100 m range that should also vary from place to place.
It´s giving me this error:
TypeError: 'float' object is not iterable