How to calculate the variance
of location details
Location has latitude
and longitude
. I am looking for a single value that will capture the variance of the location details (not separate variance for latitude and longitude). What is the best way to achieve that?
>>> pdf = pd.DataFrame({'latitude': {0: 47.0, 8: 54.0, 14: 55.0, 15: 39.0, 2: 31.0},
'longitude': {0: 29.0, 8: 10.0, 14: 36.0, 15: -9.0, 2: 121.0}
})
>>> pdf
latitude longitude
0 47.0 29.0
8 54.0 10.0
14 55.0 36.0
15 39.0 -9.0
2 31.0 121.0
As per numpy documentation, np.var
either flattens and then calculates the variance or gives per column wise.
axis None or int or tuple of ints, optional Axis or axes along which the variance is computed. The default is to compute the variance of the flattened array.
Expected (just an example)
>>> variance(pdf)
27.9
I would like to understand if the coordinates are close to each other. What is the best possible approach to get a "combined variance"?