I want to extract dates from a pandas DF that look something like this:
"{ts '2019-07-16 00:00:00'}"
I just need a yyyy-mm-dd
format. I have tried using the following code to test my regex:
date_reg_exp = re.compile('\d{4}(?P<sep>[-/])\d{2}(?P=sep)\d{2}')
# a string to test the regular expression above
test_str= "{ts '2019-07-16 00:00:00'}"
# finds all the matches of the regular expression and
# returns a list containing them
matches_list=date_reg_exp.findall(test_str)
# iterates the matching list and prints all the matches
for match in matches_list:
print (match)
Output:
-
expected output:
2019-07-16