Answer the question
In order to leave comments, you need to log in
How to parse dates to datetime format in Pandas?
There is a dataframe in which the Order Date column is a string.
I want to convert it to datetime using the code below, but it doesn't work.
dates['Datka'] = pd.to_datetime(df['Order Date'], format='%m/%d/%Y %X')
Answer the question
In order to leave comments, you need to log in
You can immediately when reading the file:
from datetime import datetime
dateparser = lambda x: datetime.strptime(x, "%m/%d/%y %H:%M")
df = pd.read_csv('filename.csv', parse_dates = ['Order Date'], date_parser=dateparser)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question