Skip to content

GH1103 Fixes for Dataframe.squeeze and Series.squeeze #1199

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 2 commits into from
Apr 26, 2025

Conversation

yangdanny97
Copy link
Contributor

@yangdanny97 yangdanny97 commented Apr 25, 2025

This PR does the following based on #1103 and https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.squeeze.html

  • add a return type annotation to Dataframe.squeeze

  • remove the axis parameter for Series.squeeze, as the docs say "For Series this parameter is unused and defaults to None."

  • add Series as a possible return type for Series.squeeze. I think since it only happens when the object is returned unchanged, the dtype is the same as the original.

  • add unit tests for the different possible returns (I'm not sure whether assert_type provides any value here, since the return is just a union)

  • Closes Series.squeeze return type should be a Series or Scalar #1103

  • Tests added: Please use assert_type() to assert the type of any return value

@yangdanny97 yangdanny97 changed the title GH1103 Fix type signatures of Dataframe.squeeze and Series.squeeze GH1103 Fixes for Dataframe.squeeze and Series.squeeze Apr 25, 2025
Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

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

thanks @yangdanny97

@Dr-Irv Dr-Irv merged commit 524cce1 into pandas-dev:main Apr 26, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Series.squeeze return type should be a Series or Scalar
2 participants