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

Allow a flag like ignoreCase for InListValidation #46

Closed Abhisek1994Roy closed 3 years ago

Abhisek1994Roy commented 3 years ago

Suppose I want to do a InListValidation and I have these two keys- ["paid", "unpaid"]. It would be great if we could ignore the case using a flag. Current options include-

  1. Adding every possible combination like- ["Paid", "PAID",.....] - not feasible
  2. Doing a Regex Match
  3. Adding custom function.
multimeric commented 3 years ago

I agree, this is a reasonable request. Unfortunately the underlying pandas function: Series.isin doesn't support this. I suppose because it needs to work regardless of whether it's dealing with text or not.

That said, I could add a case insensitive flag that converts it to lowercase, converts the provided list to lowercase also, and then calls isin. It would break if used on non-text data however.

Abhisek1994Roy commented 3 years ago

Right @TMiguelT . It can be an optional flag, which would only work for a list of strings. Let me take a stab at it and give you a pull request.

Abhisek1994Roy commented 3 years ago

@TMiguelT I cloned the code and realized that this flag is already there, and it works. Column('InterestType', [InListValidation(['flat', 'reducing'], case_sensitive=False)]), There is a case_sensitive flag, but I guess it needs to be added to the documentation.

multimeric commented 3 years ago

Huh, there you go. Well this should be sorted once I get the documentation building automatically

Abhisek1994Roy commented 3 years ago

Yep. Closing this.