multimeric / PandasSchema

A validation library for Pandas data frames using user-friendly schemas
https://multimeric.github.io/PandasSchema/
GNU General Public License v3.0
189 stars 35 forks source link

CustomValidator Error: Use `not` instead of `~` #32

Closed Ghost---Shadow closed 4 years ago

Ghost---Shadow commented 4 years ago

My CustomValidator returned True and False. But,

line 85: validation.py

says

simple_validation = ~self.validate(series)

Which does a bitwise not.

Screen Shot 2020-04-30 at 10 14 10 AM

I think the documentation needs to be more clear about the expectation or we should change to line to.

simple_validation = not self.validate(series)
multimeric commented 4 years ago

If you're using a CustomSeriesValidation (which you are evidently doing here), the documentation says that you must return a boolean Series, from your validation function, not a single boolean.

If you want to return a single boolean for each cell, you should use CustomElementValidation, or if you want to validate the whole Series as passing or failing, you can attempt to mimic IsDtypeValidation.

multimeric commented 4 years ago

Incidentally, this behaviour will be much nicer in the next major version. You will be able to return a single boolean to indicate that the whole Series has passed/failed the validation, or a boolean Series which will apply for each position in the Series.