I have dataframe that looks like below:
Date Region Data
0 200201 A 8.8
1 200201 B 14.3
...
1545 202005 C 7.3
1546 202005 D 131
I wanted to convert the Date column(data type: object) to DateTime index without time. yyyymm or yyyymmdd or yyyy-mm-dd all of these don't matter as long as I can erase the time part.
I've searched stackoverflow and tried these codes
# (1)
df["Date"] = pd.to_datetime(df["Date"], format = "%Y%m", errors = "coerce", uts = False)
# (2)
df["Date"] = pd.to_datetime(df["Date"], format = "%Y%m")
df["Date"] = df["Date"].dt.normalize()
# (3)
df["Date"] = pd.to_datetime(df["Date"], format = "%Y%m")
df["Date"] = df["Date"].dt.date
For (1) and (2), I get ["Date"] with time like yyyy-mm-dd 00:00:00.
For (3), I do get ["Date"] as yyyymm but the dtype is object.
I can't use date range because same date is repeated for some time.
Will there be any way to convert yyyymm[object] to yyyymmdd[datetime] in python?
Thanks in advance.