I'm working with some datetime data in a dataframe. It's in a format day/month/year Ex:
Date
----------------
27/06/2021 00:00
27/06/2021 00:00
30/06/2021 00:00
30/06/2021 00:00
30/06/2021 00:00
18/06/2021 00:00
26/06/2021 00:00
28/06/2021 00:00
28/06/2021 00:00
27/06/2021 00:00
28/06/2021 00:00
30/06/2021 00:00
12/06/2021 00:00
28/06/2021 00:00
I want to extract the month and year, so I converted the column to datetime using data['date'] = pd.to_datetime(data['date'])
However, this is resulting in improper classification of what is the month and what is the day. When the dates above are converted to datetime, they end up like:
Date
-----------
2021-06-27
2021-06-27
2021-06-30
2021-06-30
2021-06-30
2021-06-18
2021-06-26
2021-06-28
2021-06-28
2021-06-27
2021-06-28
2021-06-30
2021-12-06
2021-06-28
All of these dates should have 06 for June as the month. But row 13 has incorrectly assigned 12 as the month, which is leading to incorrect results when I use groupby later. Is there a way to fix this?