0

I received data from an external source that has time stamps in DDMMMYYYY format and want to convert it to MM/DD/YYYY format. Can you think of a way to do this?

Input 23-Oct-2020 27-Aug-2020 04-Dec-2019

Output that i am looking to get 10/23/2020 8/27/2020 12/04/2019

Rob
  • 1
  • 1
    Does this answer your question? [Convert Pandas Column to DateTime](https://stackoverflow.com/questions/26763344/convert-pandas-column-to-datetime) – dm2 Aug 13 '21 at 15:31

1 Answers1

1

Like this:

df['date'] =  pd.to_datetime(df['date'], format='%d-%b-%Y')
gtomer
  • 5,643
  • 1
  • 10
  • 21
  • Thanks a lot for the response. Just realized that I also have some empty rows in the data that are filled with "-" which is giving an error. Data looks like this : 0 23-Apr-2021 1 23-Mar-2021 2 - 3 03-Dec-2020 4 04-Mar-2021 5 23-Apr-2021 – Rob Aug 13 '21 at 16:25