Skip to content

Conversation

yangdanny97
Copy link
Contributor

This PR does the following for the two functions in the title:

cc @MarcoGorelli should these have tests? they're not overloaded so I'm not sure if it's necessary

@yangdanny97 yangdanny97 changed the title Improve parameter types for DataFrame.pct_change and Series.pct_change GH1169 Improve parameter types for DataFrame.pct_change and Series.pct_change Apr 22, 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.

Can you also add tests for the various arguments in test_frame.py:test_dataframe_pct_change() ?

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.

can you also add tests for Series.pct_change() in test_series.py ?

Use the check(assert_type(... pattern

@yangdanny97
Copy link
Contributor Author

I had to change the return type of Series.pct_change to get the tests to pass, I don't think the result always has the same dtype as the input.

Based on the docs, the output seems to be a series of floats, but shift is typed with UnknownSeries as the return so maybe this one should also be UnknownSeries...

@Dr-Irv thoughts?

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
Copy link
Collaborator

Dr-Irv commented Apr 24, 2025

I had to change the return type of Series.pct_change to get the tests to pass, I don't think the result always has the same dtype as the input.

Based on the docs, the output seems to be a series of floats, but shift is typed with UnknownSeries as the return so maybe this one should also be UnknownSeries...

@Dr-Irv thoughts?

You did the right thing. Series.pct_change() will return a Series[float], so I'm good with that. The previous declaration was just wrong, and existed from when we first created the repo.

@Dr-Irv Dr-Irv merged commit 18df89e into pandas-dev:main Apr 24, 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.

type kwargs in pct_change according to params in shift

3 participants