I'm importing a large number of text files and appending them to a pandas dataframe. There's a column with a bunch of dates I need, but I can't convert them to datetime because it's listed as an object. This line of code works for other any other dtype, but it throws an error when I run it here.
df['Date'] = pd.to_datetime(df['Date'], format='%m%d%y')
After running, it returns this error:
time data '01/07/2014' does not match format '%m%d%y' (match)
You can try add /
twice and change y
to Y
:
pd.to_datetime(df['Date'], format='%m/%d/%Y')
See more info about formatting datetime
in python
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With