Syntax to use df.apply() with datetime.strptime [duplicate]
问题 This question already has answers here : How to convert string to datetime format in pandas python? (2 answers) Closed 2 years ago . Consider the following table 'df': date sales 0 2021-04-10 483 1 2022-02-03 226 2 2021-09-23 374 3 2021-10-17 186 4 2021-07-17 35 I would like to convert the column date that is currently a string to a date by using apply() and datetime.strptime() . I tried the following: format_date = "%Y-%m-%d" df["date_new"] = df.loc[:,"date"].apply(datetime.strptime,df.loc[: