1

I am adding a column to my dataframe like:

df['AccountID'] = "123456789765".

I am assigning it a string value. Then I am writing the dataframe to a csv file using the to_csv method. But in the csv file the column values appear like: 1.23456E+11.

Can someone tell the reason and solution for this ?

I've already tried casting the column to object type again.

Sociopath
  • 13,068
  • 19
  • 47
  • 75
  • Possible duplicate of [Suppressing scientific notation in pandas?](https://stackoverflow.com/questions/17737300/suppressing-scientific-notation-in-pandas) – Sociopath Apr 16 '19 at 12:27
  • I don't think so. Actually my column itself is all strings(with the same value). When I am printing the dataframe in Pycharm it shows all correct values, but in the csv it is somehow getting converted(truncated). – Rajat Gupta Apr 16 '19 at 12:36

1 Answers1

0

Based on this answer here

Unfortunately excel does not allow you to turn this functionality off by default.

However if you select your data, right click, and click "Format cells..." and choose Number you can stop excel from changing your data to scientific notation.

e.g. it's not a pandas issue.

VnC
  • 1,936
  • 16
  • 26