You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Excel stores numbers as float, even numbers we enter as integers. Using the converter numbers=int truncates those floats to integers, without rounding them first. The result is that if in the cell you enter a 252, you may get a 251 when you read in python using numbers=int. That happens when the internal representation of 252 is, say, 251.999999999999423579.
I think just rounding before applying int would solve this issue nicely.
The text was updated successfully, but these errors were encountered:
You got a point there. For now, what you can do is use a lambda expression to accomplish this: xw.Range('A1').options(numbers=lambda x: int(round(x))).value. Out of curiosity, what version of Excel/OS are you using (as we can't replicate the issue for 252)?
The default behavior has now been changed on the develop branch, so using numbers=int will round the float before applying the int constructor. The rare (nonexistent?) cases where one doesn't want this behavior, one can specify numbers='raw int' and the int constructor will be applied without rounding.
Excel stores numbers as float, even numbers we enter as integers. Using the converter numbers=int truncates those floats to integers, without rounding them first. The result is that if in the cell you enter a 252, you may get a 251 when you read in python using numbers=int. That happens when the internal representation of 252 is, say, 251.999999999999423579.
I think just rounding before applying int would solve this issue nicely.
The text was updated successfully, but these errors were encountered: