I am trying to encode logic to filter a Pandas dataframe. I\'d like to encode the logic as a dictionary, with the subgroup name as the key, and the function to filter for the su
You can consider functools.partialmethod, which allows you to specify any number of args
or kwargs
:
from functools import partialmethod
mappings = {'Jets Fans': partialmethod(BaseFilter.for_jets_fans, 'Jets'),
'Patriots Fans': partialmethod(BaseFilter.for_patriots_fans, 'Patriots'),
'NFC Fans': partialmethod(BaseFilter.for_team_fans, 'Bears', 'Packers')}