I usually use numpy for my processing but I'm trying to make the most of the power of GeoPandas for my spatial data. I have some point data (shapefile) and a vector grid (fishnet) as a separate shapefile. I would like to get the points that fall within each vector grid and then do some basic statistics on them (e.g., average). Each point has an X co-ord, y co-ord and a Z value. I would like the mean value of each that falls within a grid cell.
All answers I have seen so far are either testing if one point is within a polygon, or does not go further and calculate statistics, only returning a boolean array.
From this answer I got this piece of code:
point = geopandas.GeoDataFrame.from_file(pointfile.shp)
poly = geopandas.GeoDataFrame.from_file(gridfile.shp)
pointInPolys = sjoin(point, poly, how='left')
grouped = pointInPolys.groupby('index_right')
but as I'm pretty new to Pandas I'm not sure how to get at the data in this group (or really what a group is) so I can calculate the mean value of the points. How do I get the data and perform basic statistics on it?