0

I have a pandas DataFrame with a datetime column containing two different formats. One format is “2013-03-07 05:29:47.890” Second format is unix-timestamp “1527051855673000000”

How do i convert these two datetimes into one datetime format without affecting the other.

Edit: problem is any function/processing I apply on one format will probably result in error for the other format. If I could convert one format into the other I could apply same processing to the whole column.

Ali
  • 13
  • 4
  • is your question that you want to convert the unix one into another while leaving the non-unix intact? please clarify. – etch_45 Jun 26 '21 at 22:08
  • A `datetime` object is a `datetime` object, regardless of its format. You can operate on one or both columns as you need to and format the results however you want. No object information is gained or lost by formatting. – MattDMo Jun 26 '21 at 22:13
  • @MattDMo from reading the question it appears that the different formats are in the same column – etch_45 Jun 26 '21 at 22:31
  • @etch_45 if that's the case then, I have solved something similar here - https://stackoverflow.com/questions/61418389/pandas-format-datetime-with-many-different-date-types/61423853#61423853 – tidakdiinginkan Jun 26 '21 at 23:32
  • @etch_45 now that you mention it, I see that it could be read that way. However, we need clarification from the OP before guessing at what they want. – MattDMo Jun 27 '21 at 00:02
  • @MattDMo you're right. The two formats are in the same column. – Ali Jun 27 '21 at 12:22

0 Answers0