There is a Numpy reshaping trick to do this. You can reshape your original 2D array to a 4D array where all cells which would fall in a single 50*50 grid are put into two unique dimensions. Calling any function on these axis will give you the aggregated result.
Lets make a sample 2D array:
n = 1000
grid_size = 20
grid = np.arange(n*n).reshape(n,n)
Then calculate the aggregation factor and the number of grids in both dimensions:
factor = n / grid_size
yblocks, xblocks = np.array(grid.shape) / factor
You can then reshape the original grid
array to 4 dimensions and apply the mean
on the second and fourth dimension.
grid_small = grid.reshape(yblocks, factor, xblocks, factor).mean(axis=3).mean(axis=1)
You can test it by slicing a few of the grids yourself and applying the mean on them with:
assert(grid[:factor,:factor].mean() == grid_small[0,0])
assert(grid[-factor:,-factor:].mean() == grid_small[-1,-1])
The results and difference visualized: