buggy behavior when dealing with decimals?
See original GitHub issueHey, I am dealing with this behavior and I don’t know if its a bug or I am doing something wrong:
import pandas as pd
import numpy as np
import gspread
import gspread_dataframe
from gspread_dataframe import set_with_dataframe
gc = gspread.service_account()
sh = gc.open('pandas_spreadsheet')
worksheet = sh.get_worksheet(0)
test_df = pd.DataFrame.from_records([{'a': i/500 + np.random.randn(), 'b': i * 2} for i in np.arange(0,1000,100)])
test_df
set_with_dataframe(worksheet, test_df)
Expected:
Obtained:
And if i go to the cell A1 and copy the cell value is -9622382525353560
I thought it was something with the formatting, but this number is not a float.
If I export the df using
set_with_dataframe(worksheet, test_df.round(3))
I obtain the following:
And this is a the same test in a new blank worksheet (to avoid any kind of previous formatting problems)
Please let me know if there is something that I can do to help you with a PR.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Decimal-Misconceptions-Remediation.pdf - A Learning Place
Shorter-is-larger (S) behaviour: choosing the decimal with the fewest digits after the decimal point as the largest. While these may seem incredibly naïve ......
Read more >Misconceptions about Decimal Numbers - Extranet
Apparent-Expert Behavior These students can generally decide which of two decimals is larger but sometimes not for the right reasons.
Read more >printf does not properly format decimals when using '%.8F'
Bug #78265, printf does not properly format decimals when using '%.8F' ... but there are perhaps libraries that expect the buggy behavior at ......
Read more >Javascript parse float is ignoring the decimals after my comma
Eh, no. That is seriously buggy by design. What if you are parsing a number from the 50% of the world that is...
Read more >Three decimal dimensions truncated to two ... - PTC Community
Several of these 2 decimal dimensions have been entered into family tables, and they show up as two decimal numbers, which I believe...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@ivanlen I suspect that a Google spreadsheet’s locale settings determine not just the default display formatting of numbers and dates, but also the parsing format rules when interpreting cell value inputs that are in mode
USER_ENTERED
.Would you be willing to try the following:
Manually change the locale for this Google spreadsheet to “United States”. With the sheet open in a browser, visit File->Spreadsheet settings. Then run your Python script again and see if the float values are parsed correctly as floats.
If everything works fine for your script once spreadsheet locale is “United States”, then post here what your original locale was, and we will proceed from there.
(I suspect the solution to the problem will be either:
A) Allow overrides to the
valueInputOption
value included in Sheets API cell updates; currently the package usesUSER_ENTERED
to take advantage of the powerful value parsing logic in Sheets, but it’s apparently that some users need to bypass USER_ENTERED.B) Add locale awareness to set_with_dataframe in some fashion, so that formatting inputs using values from the dataframe take the expected locale of the spreadsheet into consideration.)
@ivanlen Release 3.1.1 with this fix ya está en PyPI. Gracias por su ayuda!