pandera
pandera copied to clipboard
Refactor groupby behavior, add agg function to Checks, support error callback option
Is your feature request related to a problem? Please describe.
This issue tackles several problems with the related theme of producing more informative error messages in Check
s, see discussion in #429.
Describe the solution you'd like
The outcome of the discussion is described in https://github.com/pandera-dev/pandera/issues/429#issuecomment-811045571
- [ ] refactor
groupby
behavior to expect a pandasGroupby
object (breaking change) - [ ] add
agg
kwarg toCheck
that simply wraps DataFrame.agg and Series.agg depending on the schema context - [ ] support callback function for the
error
kwarg:
CheckObj = Union[pd.Series, pd.DataFrame, pd.Groupby] # series or dataframe can be the output of `agg` operation
def error_callback(check_obj: CheckObj, check_output) -> str:
return f"check failed with values {check_obj}, check output: {check_output}"
What's the status of this? I'm running into a use case where I need the exact functionality described in #872.
I'm currently just raising an error in the check if it fails to help debug, but would love to have this be part of the tool.
hi @christopher-hacker this is ready to be worked on, no one is currently owning this. Would you be interested in making a contribution?