Skip to content
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

BUG: SparseArray.map allows the fill value to be included in the sparse values #52095

Closed
3 tasks done
topper-123 opened this issue Mar 20, 2023 · 0 comments · Fixed by #52096
Closed
3 tasks done

BUG: SparseArray.map allows the fill value to be included in the sparse values #52095

topper-123 opened this issue Mar 20, 2023 · 0 comments · Fixed by #52096
Labels
Bug Sparse Sparse Data Type

Comments

@topper-123
Copy link
Contributor

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
>>> sp = pd.arrays.SparseArray([1, np.nan])
>>> mapped = sp.map(lambda x: np.nan)
>>> pd.isna(mapped.fill_value)
True
>>> pd.isna(mapped.sp_values)[0]
True

Issue Description

The current implementation of SparseArray.map allows the fill value to be included in the sparse values, causing potential problems.

Expected Behavior

SparseArray.map It should raise or recalculate the sparse array.

Installed Versions

Replace this line with the output of pd.show_versions()

@topper-123 topper-123 added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Mar 20, 2023
@lithomas1 lithomas1 added Sparse Sparse Data Type and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Mar 21, 2023
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

Successfully merging a pull request may close this issue.

2 participants