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

DEPR: require SparseDtype.fill_value be compatible with SparseDtype.subtype #53043

Merged
merged 4 commits into from
May 11, 2023

Conversation

jbrockmendel
Copy link
Member

stacklevel=find_stack_level(),
)
elif isinstance(self.subtype, CategoricalDtype):
# TODO: is this even supported? It is reached in
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could see it being reasonable to have a fill value for a Categorical that's not a current category but is the same type as the current categories

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in principle i guess, but i think this case existing at all is wrong. SparseArray._sparse_values has to be np.ndarray, and the dtype is initialized with self._dtype = SparseDtype(sparse_values.dtype, fill_value)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will make a separate PR to disallow this case

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#53160 disallows this case

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should no longer be an issue now that #53160 is merged

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

woops, should have updated to remove this check. will do in a follow-up

@mroeschke mroeschke added Sparse Sparse Data Type Deprecate Functionality to remove in pandas labels May 11, 2023
@mroeschke mroeschke added this to the 2.1 milestone May 11, 2023
@mroeschke mroeschke merged commit 45eb702 into pandas-dev:main May 11, 2023
@mroeschke
Copy link
Member

Thanks @jbrockmendel

@jbrockmendel jbrockmendel deleted the depr-sparse-fill_value branch May 11, 2023 20:27
Rylie-W pushed a commit to Rylie-W/pandas that referenced this pull request May 19, 2023
…ubtype (pandas-dev#53043)

* DEPR: require SparseDtype.fill_value be compatible with SparseDtype.subtype

* filter more specific
Daquisu pushed a commit to Daquisu/pandas that referenced this pull request Jul 8, 2023
…ubtype (pandas-dev#53043)

* DEPR: require SparseDtype.fill_value be compatible with SparseDtype.subtype

* filter more specific
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deprecate Functionality to remove in pandas Sparse Sparse Data Type
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Require the dtype of SparseArray.fill_value and sp_values.dtype to match
2 participants