Skip to content

pandas 2.2.1 introduce API changes, for example for groupby().first, groupby().last and series.argsort #57631

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

Closed
anmyachev opened this issue Feb 26, 2024 · 9 comments
Labels
Closing Candidate May be closeable, needs more eyeballs

Comments

@anmyachev
Copy link
Contributor

This makes code written in Pandas 2.2.1 incompatible with 2.2.0.

Was this done by mistake or on purpose? As far as I know, Pandas follows the semver methodology and this change is unexpected for me.

@mroeschke
Copy link
Member

Not sure about the argsort change. Would be great to see an example of the change.

The other change is expected as noted in https://pandas.pydata.org/docs/whatsnew/v2.2.1.html#other and detailed in #57102 cc @rhshadrach

@mroeschke mroeschke added the Needs Info Clarification about behavior needed to assess issue label Feb 26, 2024
@anmyachev
Copy link
Contributor Author

Not sure about the argsort change. Would be great to see an example of the change.

In pandas 2.2.1 (in comparison with 2.2.0) https://pandas.pydata.org/docs/reference/api/pandas.Series.argsort.html#pandas.Series.argsort has a new stable parameter.

@mroeschke
Copy link
Member

I see thanks for point that out.

This PR introduced that change and was meant to give pandas 2.2.x potential compatibility with Numpy 2.0 when it comes out: #57057. Sorry for not documenting it in the what's new, but the new argument was made backward compatible and doesn't change the behavior of argsort

@mroeschke mroeschke added Closing Candidate May be closeable, needs more eyeballs and removed Needs Info Clarification about behavior needed to assess issue labels Feb 26, 2024
@anmyachev
Copy link
Contributor Author

@mroeschke just to be sure, pandas patch releases only guarantee backward compatibility and not forward compatibility?

@mroeschke
Copy link
Member

I'm a little confused what forward compatible means in this context, but these changes will also apply to the next minor/major release (3.0)

@anmyachev
Copy link
Contributor Author

I mean a situation where, for example, the code is written with the new parameters existing for version 2.2.1, but the user encountered some kind of error and decided to run the same code on pandas 2.2.0 (where parameters may not yet exist). Can one expect the code to work?

@rhshadrach
Copy link
Member

As far as I know, Pandas follows the semver methodology and this change is unexpected for me.

pandas uses a loose variant of semantic versioning SemVer to govern deprecations, API compatibility, and version numbering.

In the case of groupby first/last, the decision to add in 2.2.1 was made because we accidentally removed the ability of users to achieve the result with skipna=False in 2.0, and this was only brought to our attention as part of the 2.2.x development.

@mroeschke
Copy link
Member

the code is written with the new parameters existing for version 2.2.1, but the user encountered some kind of error and decided to run the same code on pandas 2.2.0 (where parameters may not yet exist). Can one expect the code to work?

For this example, no argsort with stable usage written in 2.2.1 will not be expected to work in 2.2.0

@anmyachev
Copy link
Contributor Author

@mroeschke @rhshadrach thanks for the clarification! I received answers to all the questions, I think the issue can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closing Candidate May be closeable, needs more eyeballs
Projects
None yet
Development

No branches or pull requests

3 participants