0

I’m working with a data frame and need to include additional columns(series) with some data validation of the original data. I’ve programmed most of them, but I don’t know how to program a validation such as below in python:

Test: The "Record Date" field must be completed with a valid date, in the format 'YYYY-MM-DD'.

I need to find a way to validate that and bring the results as True or False in a new column in the data frame. Is there any function to verify if a date is in a specific format like 'YYYY-MM-DD'?

Appreciate the help!

Tegman
  • 15
  • 2
  • Something like `df['validate'] = pd.to_datetime(df['date'], format='%Y-%m-%d', errors='coerce').notnull()`? Adapted from [Pandas validate date format](https://stackoverflow.com/q/49435438/15497888) – Henry Ecker Sep 15 '21 at 20:29
  • It worked! Thanks a lot! – Tegman Sep 16 '21 at 12:30

0 Answers0