0

I have a column in a dataframe with multiple date formats that need to be converted to datetime.

date              amount
September 2018    15
Sep-18            20

The output should look like

date              amount
2018-09-01        15
2018-09-01        20

Using pd.to_datetime(df['Month']) returns the error...

OutOfBoundsDatetime: Out of bounds nanosecond timestamp: 1-09-18 00:00:00

6
  • why sep 2018 return 2017 ? Commented Oct 3, 2018 at 2:18
  • sorry, that was a typo Commented Oct 3, 2018 at 2:19
  • and why sep-18 is not 2018-09-18 since for me this is make more sense . Commented Oct 3, 2018 at 2:20
  • Sep-18 is in the format Mmm-YY, so needs to be converted to a month and year date format Commented Oct 3, 2018 at 2:22
  • Extracting dates that are in different formats using regex and sorting them - pandas This might help. But needs a bit of alteration. Commented Oct 3, 2018 at 2:23

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.