pandera: Is there a way to generate informative error on custom checks?
Hello,
Iām trying to create a custom check such as
Check(lambda g: g.mean() >0.1, error="mean over 0.1")
Is there a way adding more info to the error message such as f"mean over 0.1 and the current mean is {g.mean()}"?
Thanks š
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15
Action Items
groupbybehavior to expect a pandasGroupbyobjectaggkwarg toCheckthat simply wraps DataFrame.agg and Series.agg depending on the schema contexterrorkwarg:If the additional
aggargument feels too clunky, we can go the direction of specializedGroupbyCheckandAggChecksubclasses.I can give a shot at implementing this!
yeah, the implementation for (3) at validation time (
Check.__call__) would do something like:So you can do something like
Or
Of course specifying an
agg_fnwould raise an exception ifelement_wise == Trueorgroupbyis specified.