In DE_Tools see: https://github.com/rhyslwells/DE_Tools/blob/main/Explorations/Transformation/selection.ipynb