I am trying to convert a datetime object to datetime. In the original dataframe the data type is a string and the dataset has shape = (28000000, 26). Importantly, the format of the date is MMYYYY only. Here's a data sample:
                       DATE
Out[3]    0           081972
          1           051967
          2           101964
          3           041975
          4           071976
I tried:
df['DATE'].apply(pd.to_datetime(format='%m%Y'))
and
pd.to_datetime(df['DATE'],format='%m%Y')
I got Runtime Error both times
Then
df['DATE'].apply(pd.to_datetime)
it worked for the other not shown columns(with DDMMYYYY format), but generated future dates with df['DATE'] because it reads the dates as MMDDYY instead of MMYYYY.
            DATE
0       1972-08-19
1       2067-05-19
2       2064-10-19
3       1975-04-19
4       1976-07-19
Expect output:
          DATE
0       1972-08
1       1967-05
2       1964-10
3       1975-04
4       1976-07
If this question is a duplicate please direct me to the original one, I wasn't able to find any suitable answer.
Thank you all in advance for your help
 
     
     
    