I have the following dataframe:
Data
0 12/25/2020
1 10/25/2020
2 2020-09-12 00:00:00
3 2020-12-09 00:00:00
I'm using the following (python) code to extract the first two potential numbers to represent a month:
df['Data'].apply(lambda x: re.match('.*([1-2][0-9]{3})', x).group(1))
However, it returns a NaN dataframe. When i test it in regex101, it works (link: https://regex101.com/r/QpacQ0/1). So, i have two questions:
- Is there a better way to work with dates from an user input? I mean, i'm building a script to recognize by position and then convert to a datetime object.
- And second, why can't this code recognize the months?