0

Despite I had value to pandas data frame as string, it is being transformed to date format when I export data frameenter image description here to CSV file.

I have tried various methods, but the outcome is the same.

Did anyone have a similar problem? If yes, how did you solve it?

YIF99
  • 51
  • 1
  • 8
  • 2
    Note that CSV is not a synonym of Excel. This behavior is Excel trying to be helpful (and failing). If you need a string, then *import* the CSV into Excel, specifying that column as text. – BigBen Oct 21 '22 at 16:28
  • Does this answer your question? [How to change the datetime format in Pandas](https://stackoverflow.com/questions/38067704/how-to-change-the-datetime-format-in-pandas) – LazyClown Oct 21 '22 at 16:30
  • 1
    Echoing @BigBen above, what is displayed when you open the CSV in notepad? – JonTout Oct 21 '22 at 16:31
  • in notepad, it is fine(the format of column is not being changed) – YIF99 Oct 27 '22 at 15:00

1 Answers1

2

I think it has nothing to do with pandas or python but with the excel or google docs or any other spreadsheet software you are using.

In the case of excel, you can use =TEXT(date, format) to convert the date into the text format.

EDIT:
You can also specify the column as text instead of using formula.