Skip to content

DEPR: Enforce deprecation of previous implementation of DataFrame.stack #57302

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

Merged
merged 5 commits into from
Feb 14, 2024

Conversation

rhshadrach
Copy link
Member

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Tests added and passed if fixing a bug or adding a new feature
  • All code checks passed.
  • Added type annotations to new arguments/methods/functions.
  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

Ref: #53515

We need to keep the future_stack argument in 3.0, but have two choices: still allow users to specify future_stack=False (while always seeing the warning message) or remove future_stack=False entirely now. In either case, we'd introduce a deprecation of the future_stack argument (regardless of how it's being specified) as part of 3.x (I plan on 3.1).

I went with the former option of still allowing future_stack=False - it seemed more gradual.

@rhshadrach rhshadrach added the Reshaping Concat, Merge/Join, Stack/Unstack, Explode label Feb 8, 2024
@rhshadrach rhshadrach added this to the 3.0 milestone Feb 8, 2024
@simonjayhawkins simonjayhawkins added the Deprecate Functionality to remove in pandas label Feb 8, 2024
@simonjayhawkins
Copy link
Member

We need to keep the future_stack argument in 3.0

that's unfortunate.

@@ -28,6 +28,9 @@ def future_stack(request):


class TestDataFrameReshape:
@pytest.mark.filterwarnings(
"ignore:The previous implementation of stack is deprecated"
Copy link
Member

@mroeschke mroeschke Feb 8, 2024

Choose a reason for hiding this comment

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

Will there still be appetite to fix the future_stack=False case in 3.x? If not I would be OK only testing future_stack=True

Copy link
Member Author

Choose a reason for hiding this comment

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

I stated in #57152 (comment) that PRs to fix an issue with stack are welcome, but this made me rethink that. One potential consideration is that a bugfix can inadvertently introduce new issues. For this reason, I'm now thinking for a deprecated behavior we should prefer stability over bugfixes.

I'll remove the tests.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry - I've come full circle on this. If you're okay with it, I'd rather leave the tests in for now in case something unanticipated occurs.

@mroeschke
Copy link
Member

Also were you thinking of deprecating dropna and sort in this PR as well?

@rhshadrach
Copy link
Member Author

Also were you thinking of deprecating dropna and sort in this PR as well?

Currently if you use future_stack=True we raise when dropna or sort are specified. So I don't think any action needs to be taken here.

@mroeschke
Copy link
Member

OK but in a follow up they will be deprecated then? I see from the 2.1 whatsnew

As such, the arguments dropna and sort are not utilized and must remain unspecified when using future_stack=True. These arguments will be removed in the next major release.

@rhshadrach
Copy link
Member Author

I don't think there is a need to deprecate them - they must remain unspecified and so removing them is backwards compatible. In other words, if you run pandas 2.x (or 3.x) without any warnings, then your code will be fine in 4.0.

# Conflicts:
#	doc/source/whatsnew/v3.0.0.rst
Copy link
Member

@mroeschke mroeschke left a comment

Choose a reason for hiding this comment

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

So in 4.0 we can just remove sort and dropna from the signature of stack?

Just a merge conflict otherwise looks good

# Conflicts:
#	doc/source/whatsnew/v3.0.0.rst
@rhshadrach
Copy link
Member Author

So in 4.0 we can just remove sort and dropna from the signature of stack?

Correct.

@mroeschke mroeschke merged commit 44c50b2 into pandas-dev:main Feb 14, 2024
@mroeschke
Copy link
Member

Thanks @rhshadrach

@rhshadrach rhshadrach deleted the enf_dataframe_stack branch February 14, 2024 03:01
@rhshadrach rhshadrach added Clean and removed Deprecate Functionality to remove in pandas labels Feb 14, 2024
pmhatre1 pushed a commit to pmhatre1/pandas-pmhatre1 that referenced this pull request May 7, 2024
…ck (pandas-dev#57302)

* DEPR: Enforce deprecation of previous implementation of DataFrame.stack

* fixup

* whatsnew
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants