I have a string which is similar to this
02032021..........SW01SW05..........
I have already extracted everything I need from it except for the date which is the first block of digits. the dates are between Jan 21 and YTD.
I used this code to get only the digits df.loc[x, "Date Worked"] = df["Worked In Cost Number"].str.slice(0,10).astype(str)
x is subset which contains strings with the same format.
and then I tried to convert it to date df["Date Worked"] = pd.to_datetime(df["Date Worked"].str.slice(0,2) + df["Date Worked"].str.slice(2,4)+ df["Date Worked"].str.slice(4,8), format = '%m%d%Y')
but when i do that i get this error
OutOfBoundsDatetime: Out of bounds nanosecond timestamp: 3202-03-12 00:00:00
I the issue is that when I slice it, it turns into a float and dismisses the leading zero.