8

I have an excel file produced automatically with occasional very large numbers like 135061808695. In the excel file when you click on the cell it shows the full number 135061808695 however visually with the automatic "General" format the number appears as 1.35063E+11.

When I use ExcelFile in Pandas the it pulls the value in scientific notation 1.350618e+11 instead of the full 135061808695. Is there any way to get Pandas to pull the full value without going in an messing with the excel file?

pnuts
  • 58,317
  • 11
  • 87
  • 139
rhaskett
  • 1,864
  • 3
  • 29
  • 48
  • A (very) brief glance at the API suggests no, but, what's wrong with converting that scientific notation into a plain number with your own code? – tenwest Apr 14 '15 at 23:44
  • 2
    Pandas might very well be pulling the "full value". Just because it's displaying ```1.35063e+11``` doesn't mean there isn't more precision stored. Print out with a format like ```15.0f``` to check. – JohnE Apr 15 '15 at 01:48
  • Ahh... @JohnE you are correct. Its actually when I round trip and store the information down that I truly lose the precision though it appeared that I lost it earlier. This was easy to fix. If you want to write up a quick answer below I'll give you credit. – rhaskett Apr 15 '15 at 17:45

1 Answers1

7

Pandas might very well be pulling the full value but not showing it in its default output:

df = pd.DataFrame({ 'x':[135061808695.] })

df.x
0    1.350618e+11  
Name: x, dtype: float64

Standard python format:

print "%15.0f" % df.x
135061808695

Or in pandas, convert to an integer type to get integer formatting:

df.x.astype(np.int64)

0    135061808695
Name: x, dtype: int64
JohnE
  • 29,156
  • 8
  • 79
  • 109