pandera icon indicating copy to clipboard operation
pandera copied to clipboard

Refactor groupby behavior, add agg function to Checks, support error callback option

Open cosmicBboy opened this issue 3 years ago • 2 comments

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 Checks, 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 pandas Groupby object (breaking change)
  • [ ] add agg kwarg to Check 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}"

cosmicBboy avatar May 08 '21 16:05 cosmicBboy

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.

cmhac avatar Sep 25 '23 16:09 cmhac

hi @christopher-hacker this is ready to be worked on, no one is currently owning this. Would you be interested in making a contribution?

cosmicBboy avatar Sep 25 '23 16:09 cosmicBboy