If you can write an Excel formula, you can build your own function.
Squidpy is the scverse toolkit for scalable analysis and visualization of spatial molecular data. It builds on scanpy and anndata, providing streamlined APIs for feature extraction, spatial statistics ...
A boring setting with huge payoff.