-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
Description
Pandas version checks
-
I have checked that this issue has not already been reported.
-
I have confirmed this bug exists on the latest version of pandas.
-
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
from pandas.io.formats.format import EngFormatter
def test_eng_formatter():
formatter4 = EngFormatter(use_eng_prefix=True, accuracy=4)
formatter5 = EngFormatter(use_eng_prefix=True, accuracy=5)
assert formatter4(12_345_678.90) == "123.5M"
assert formatter5(12_345_678.90) == "123.46M"
assert formatter4(0.0001234567890) == "123.5u"
assert formatter5(0.01234567890) == "12.346m"
test_eng_formatter()Issue Description
The accuracy argument of the EngFormatter is generating a different number of digits.
It is expected to obtain 5 digits in total with accuracy=5, but the argument seems to affect only the digits behind the decimal point. This is wrong. It is not Engineering Notation !
Expected Behavior
Example:
with accuracy=4
- 12_345_678.90 returns 12.3457M , expected : 12.35M
- 123.4568u returns 123.4568u, expected 123.5u
with accuracy=5
- 12_345_678.90 returns 12.34568M, expected 12.345M
- 0.01234567890 returns 12.34568m, expected 12.346m
Installed Versions
pandas : 2.3.3
numpy : 2.0.2
pytz : 2025.2
dateutil : 2.9.0.post0
pip : 21.3.1
Cython : None
sphinx : None
IPython : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : None
blosc : None
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : None
html5lib : None
hypothesis : None
gcsfs : None
jinja2 : None
lxml.etree : 4.6.5
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
psycopg2 : None
pymysql : None
pyarrow : None
pyreadstat : None
pytest : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlsxwriter : None
zstandard : None
tzdata : 2025.2
qtpy : None
pyqt5 : None