I have a bunch of geographical data as below. I would like to group the data by bins of .2 degrees in longitude AND .2 degree in latitude.
While it is trivial to do
How about this?
step = 0.2 to_bin = lambda x: np.floor(x / step) * step df["latbin"] = df.Latitude.map(to_bin) df["lonbin"] = df.Longitude.map(to_bin) groups = df.groupby(("latbin", "lonbin"))