-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
API: Add pandas.api.typing #48578
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
API: Add pandas.api.typing #48578
Conversation
Marking this as a draft until the discussion in the corresponding issue is resolved. |
Can you merge main? |
@phofl - done. |
This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this. |
55702b0
to
ea91291
Compare
3831209
to
8f953a5
Compare
@simonjayhawkins - friendly ping |
…pby_in_api � Conflicts: � doc/source/whatsnew/v2.1.0.rst
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @rhshadrach lgtm pending green. and conflicts to resolve
I think this could be coupled to #27522, so as a follow-up or here if others think that the coupling is strong (e.g. need for api namespace)
…pby_in_api � Conflicts: � doc/source/whatsnew/v2.1.0.rst
Thanks @simonjayhawkins for the review
The issue with the Styler is still a blocker here, and I plan to address it in a followup PR. Last I looked, it would require a bit of refactoring. Because of this and the amount of changes deprecating pandas.core would take, I'm quite resistant to including such work here. |
sure. if we deprecate core it would enforce the usage of pandas[.api].typing but I guess changing the api docs for the public classes currently in core is a step in the right direction. |
…pby_in_api # Conflicts: # doc/source/whatsnew/v2.1.0.rst
@simonjayhawkins - friendly ping |
@Dr-Irv - friendly ping. |
@rhshadrach I may be being a bit pedantic here, but now the docs don't correspond to what happens at runtime, and maybe you should add tests for this. Consider this: >>> import pandas as pd
>>> df=pd.DataFrame({"x":[i for i in range(10)]}, index=pd.date_range("230101", periods=10))
>>> df
x
2001-01-23 0
2001-01-24 1
2001-01-25 2
2001-01-26 3
2001-01-27 4
2001-01-28 5
2001-01-29 6
2001-01-30 7
2001-01-31 8
2001-02-01 9
>>> df.resample("2d")
<pandas.core.resample.DatetimeIndexResampler object at 0x000002425662CF40>
>>> type(df.rolling(2))
<class 'pandas.core.window.rolling.Rolling'> So the docs are saying that Now it is probably the case that the type I'm probably suggesting this because when we change things in pandas-stubs to correspond to this change, we will end up creating those tests there (in a slightly different form) |
Thanks @Dr-Irv - it's an interesting point. But is there something that can be done here? For example, within
with
I still see
|
I don't think we want to through the effort of changing the returned classes, but I think you can create a test like this: gb = pd.DataFrame({'a': [1, 1, 2], 'b': [3, 4, 5]}).groupby('a')
assert isinstance(gb, pd.api.typing.DataFrameGroupBy) That would at least test that you've correctly mapped the types in the |
from pandas.io.stata import StataReader | ||
|
||
__all__ = [ | ||
"DataFrameGroupBy", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just commenting that in a follow up PR it might make sense for these objects to have their own API Reference page?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea - agreed. I can open an issue to track.
But there is no mapping here, yea? We import the object and then include said object in I don't think such a test is warranted, and I'll also note we don't have tests like this for any existing |
Maybe "mapping" is the wrong word. I'm thinking of the following. Suppose that someone removed one of the types from Just because we don't have tests for the other |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally LGTM
…pby_in_api � Conflicts: � doc/source/whatsnew/v2.1.0.rst
Ah, I was under the false impression that this was being done. Agreed we should be testing this! I've added the ones for api.typing and plan to do the others in a followup (I've opened #52688 to track). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @rhshadrach . Let me know if I should do the merge, or if someone else should do it.
…pby_in_api � Conflicts: � doc/source/whatsnew/v2.1.0.rst
Thanks @rhshadrach |
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.