Skip to content

BUG: AttributeError: 'SparseArray' object has no attribute 'round' #61252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 of 3 tasks
ShuyangXu opened this issue Apr 8, 2025 · 2 comments
Closed
2 of 3 tasks

BUG: AttributeError: 'SparseArray' object has no attribute 'round' #61252

ShuyangXu opened this issue Apr 8, 2025 · 2 comments
Labels
Bug Sparse Sparse Data Type

Comments

@ShuyangXu
Copy link

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

import pandas as pd
df = pd.DataFrame([1.1,2.5,3,4.7], dtype = pd.SparseDtype())

hasattr(df, 'round')
# True

df.round()
# AttributeError: 'SparseArray' object has no attribute 'round'

Issue Description

the sparsed df do has round method, but can not execute it

Expected Behavior

df can execute round method

Installed Versions

INSTALLED VERSIONS

commit : 0691c5c
python : 3.13.2
python-bits : 64
OS : Linux
OS-release : 3.10.0-1160.102.1.0.1.an7.x86_64
Version : #1 SMP Sun Oct 29 06:40:18 CST 2023
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : en_US.utf8
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 2.2.3
numpy : 2.2.4
pytz : 2025.2
dateutil : 2.9.0.post0
pip : 25.0.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 : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : 3.1.5
pandas_gbq : None
psycopg2 : None
pymysql : None
pyarrow : None
pyreadstat : None
pytest : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : 1.15.2
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : 2.0.1
xlsxwriter : None
zstandard : None
tzdata : 2025.2
qtpy : None
pyqt5 : None

@ShuyangXu ShuyangXu added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Apr 8, 2025
@fenil1307
Copy link

Hi! 👋 I’d like to work on this issue. I can reproduce the bug as described and will look into adding support for .round() on SparseArray. Let me know if this is okay to proceed.

@asishm asishm added the Sparse Sparse Data Type label Apr 8, 2025
@rhshadrach
Copy link
Member

Closing as a duplicate of #49387. That issue has a PR linked to it, and that PR does indeed resolve this issue.

@rhshadrach rhshadrach removed the Needs Triage Issue that has not been reviewed by a pandas team member label Apr 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Sparse Sparse Data Type
Projects
None yet
Development

No branches or pull requests

4 participants