Open cosmicBboy opened 2 years ago
What about, eg, returning a Result from Validate? That would allow the user to do something with the Failure, like log the failed df
for examination.
I'm guessing Success
type would be a breaking change? i.e. I get a Success
object instead of a DataFrame
, right?
I'd hesitate to introduce this breaking change until perhaps version 1.*
of pandera, or perhaps introduce a different method that implements this behavior.
Definitely a breaking change and likely not something you'd want as a default. Most people probably wouldn't be expecting it.
But it could be implemented either as a return_monad: bool
argument in validate; or even easier like you said is a separate method that just wraps validate in a try ... except ...
and returns a Result
in either case. The Failure
case could also return the df
of failing values for the user to do something with.
I'm not super familiar with the source code so there may be a better way to implement, but that's off the top of my head.
https://returns.readthedocs.io/
Use case: for the
model.SchemaModel
class, we want to be able to support higher kinded types in methods e.g. thevalidate
method, such that it can return type-varying generics based on the type of thecheck_obj
argument.https://returns.readthedocs.io/en/latest/pages/hkt.html