I noticed that when certain Numfl float64 values ββare saved as an Excel file (via Pandas DataFrame), they change. At first I thought this was due to some inaccuracy in Excel, but Excel seems to encode floating-point numbers as double precision, so I'm a little confused by this observation.
>>> import numpy as np
>>> import pandas as pd
>>> ba = bytearray(['\x53', '\x2a', '\xb0', '\x49', '\xf3', '\x79', '\x90', '\x40'])
>>> ba
bytearray(b'S*\xb0I\xf3y\x90@')
>>> f = np.frombuffer(ba)
>>> f[0]
1054.4875857854684
>>> df = pd.DataFrame({'a': f})
>>> df.to_excel('test.xlsx', engine='xlsxwriter')
>>> df2 = pd.read_excel('test.xlsx')
>>> df2.ix[0,'a']
1054.4875857854699
>>> df2.ix[0,'a'] == f[0]
False
Why is it impossible to read the same float64 file from a previously written Excel?
Openpyxl ( .xlsx) Xlwt ( .xls) . , xlsxwriter, Xlwt float . , , .xlsx?
>>> df.to_excel('test.xls')
>>> df2 = pd.read_excel('test.xls')
>>> df2.ix[0,'a'] == f[0]
True