Skip to content

DEPR: upcasting on invalid fill_value in unstack #53868

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

Open
3 tasks done
jbrockmendel opened this issue Jun 26, 2023 · 0 comments
Open
3 tasks done

DEPR: upcasting on invalid fill_value in unstack #53868

jbrockmendel opened this issue Jun 26, 2023 · 0 comments
Labels
Deprecate Functionality to remove in pandas Dtype Conversions Unexpected or buggy dtype conversions Needs Discussion Requires discussion from core team before further action Reshaping Concat, Merge/Join, Stack/Unstack, Explode

Comments

@jbrockmendel
Copy link
Member

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

ser = pd.Series([1, 2, None, 4, 5, None])
ser.index = pd.MultiIndex.from_arrays([range(6), range(6, 12)])

>>> ser.unstack(fill_value="a")
    6    7    8    9    10   11
0  1.0    a    a    a    a    a
1    a  2.0    a    a    a    a
2    a    a  NaN    a    a    a
3    a    a    a  4.0    a    a
4    a    a    a    a  5.0    a
5    a    a    a    a    a  NaN

Issue Description

ATM in unstack (specifically in _Unstacker.get_new_values) we pass a fill_value to maybe_promote which upcasts on fill_values that can't be held normally. We only do this for numpy dtypes, not EADtypes, which is a not-great inconsistency.

In the spirit of PDEP-6, should we consider deprecating this upcasting? Or like in #53802, maybe allow int->float?

Expected Behavior

NA

Installed Versions

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

@jbrockmendel jbrockmendel added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Jun 26, 2023
@lithomas1 lithomas1 added Reshaping Concat, Merge/Join, Stack/Unstack, Explode Dtype Conversions Unexpected or buggy dtype conversions Deprecate Functionality to remove in pandas and removed Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Jun 26, 2023
@jbrockmendel jbrockmendel added the Needs Discussion Requires discussion from core team before further action label Jun 28, 2023
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 Dtype Conversions Unexpected or buggy dtype conversions Needs Discussion Requires discussion from core team before further action Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

No branches or pull requests

2 participants