Skip to content

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