-3

I can convert string column to datetime column; pd.to_datetime(data['Document Date']) . But how to convert datetime to string back again?

Ratha
  • 9,434
  • 17
  • 85
  • 163

1 Answers1

0

data['Document Date'] = data.apply(lambda x: str(x)) should work.

If your string was formatted in a different way than the default representation of a date in pandas, then you won't be able to convert back to the original string format: that data is lost in the conversion. If this is the case, I recommend you simply create a new column that stores the converted datetime, alongside the existing string column.