Pandera question: Check format of date (yyyy-mm-dd) #1041
-
I created a schema definition for the validation of a df. Now I have a question: Is it possible to check whether a column has a certain format, the column in question is of datetime type and information uploaded should be in the form of yyyy-mm-dd, however excel sometimes changes this to yyyy-dd-mm when uploaded. The validation is to make sure that the format within the row stays in the form of yyy-mm-dd. Is there a check possible which checks whether it is in the format yyy-mm-dd. The schema object is written to a yaml file, so in yaml form. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
hi @jonathangebru, unfortunately schemas written in yaml aren't as flexible as Python ones... I'm guessing you care about preserving the datatype of the datetime column? If not you can use the Perhaps a feature enhancement of that check is to convert incoming data into a |
Beta Was this translation helpful? Give feedback.
hi @jonathangebru, unfortunately schemas written in yaml aren't as flexible as Python ones...
I'm guessing you care about preserving the datatype of the datetime column? If not you can use the
str_matches
check: https://pandera.readthedocs.io/en/stable/reference/generated/methods/pandera.checks.Check.str_matches.html#pandera.checks.Check.str_matchesPerhaps a feature enhancement of that check is to convert incoming data into a
str
so that the regex pattern can be matched against the string-coerced data instead of the original datatype.