Skip to content

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

Merged
merged 37 commits into from
Apr 17, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
ea91291
API: Add pandas.api.typing
rhshadrach Sep 9, 2022
985627c
whatsnew note
rhshadrach Dec 31, 2022
1114428
Merge branch 'main' into groupby_in_api
rhshadrach Jan 1, 2023
d4e6e09
Don't import Styler
rhshadrach Jan 1, 2023
3dd6cf8
Test fixup for Styler
rhshadrach Jan 2, 2023
8f953a5
API: Add pandas.api.typing
rhshadrach Sep 9, 2022
d00861e
Merge branch 'main' into groupby_in_api
rhshadrach Jan 22, 2023
e94061f
Add back Styler
rhshadrach Jan 23, 2023
b3abf13
Merge branch 'main' of https://github.com/pandas-dev/pandas into grou…
rhshadrach Jan 23, 2023
236e99d
Merge branch 'groupby_in_api' of https://github.com/rhshadrach/pandas…
rhshadrach Jan 23, 2023
d4f39d4
Merge branch 'groupby_in_api' of https://github.com/rhshadrach/pandas…
rhshadrach Jan 23, 2023
3f63dd5
Merge branch 'main' of https://github.com/pandas-dev/pandas into grou…
rhshadrach Jan 24, 2023
44edcdb
Revert Styler changes
rhshadrach Jan 24, 2023
04a88d9
Point to pandas.api.typing for GroupBy objects
rhshadrach Jan 24, 2023
b11b21b
Merge branch 'main' of https://github.com/pandas-dev/pandas into grou…
rhshadrach Feb 6, 2023
7a8b1aa
Add references to pandas.api.typing
rhshadrach Feb 6, 2023
b0423af
fixup
rhshadrach Feb 11, 2023
79fe367
Merge branch 'main' of https://github.com/pandas-dev/pandas into grou…
rhshadrach Feb 11, 2023
940a33e
Refinements
rhshadrach Feb 11, 2023
b558c0a
Merge branch 'main' of https://github.com/pandas-dev/pandas into grou…
rhshadrach Feb 14, 2023
56a2480
Add references to User Guide; fixup docstrings
rhshadrach Feb 14, 2023
0e279f4
Add references
rhshadrach Feb 14, 2023
edaa9c3
Merge branch 'groupby_in_api' of https://github.com/rhshadrach/pandas…
rhshadrach Feb 14, 2023
1b8189c
fixup
rhshadrach Feb 14, 2023
3506ea6
Merge branch 'main' of https://github.com/pandas-dev/pandas into grou…
rhshadrach Feb 14, 2023
433040c
Merge branch 'main' of https://github.com/pandas-dev/pandas into grou…
rhshadrach Feb 24, 2023
0dd0e2e
Move whatsnew to 2.1.0
rhshadrach Feb 24, 2023
45de284
Merge branch 'main' of https://github.com/pandas-dev/pandas into grou…
rhshadrach Feb 26, 2023
781ff4a
Merge branch 'main' of https://github.com/pandas-dev/pandas into grou…
rhshadrach Mar 4, 2023
cd40744
Merge branch 'main' of https://github.com/pandas-dev/pandas into grou…
rhshadrach Mar 9, 2023
0e8cb7a
Docstring fixup
rhshadrach Mar 17, 2023
cf1d68b
Merge branch 'main' of https://github.com/pandas-dev/pandas into grou…
rhshadrach Mar 17, 2023
bb164e5
Merge branch 'main' into groupby_in_api
simonjayhawkins Mar 17, 2023
621b37e
Merge branch 'main' into groupby_in_api
rhshadrach Apr 8, 2023
df0d343
Test dir of api.typing
rhshadrach Apr 16, 2023
9f868f1
Merge branch 'main' of https://github.com/pandas-dev/pandas into grou…
rhshadrach Apr 16, 2023
4689965
Merge branch 'main' of https://github.com/pandas-dev/pandas into grou…
rhshadrach Apr 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions doc/source/reference/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,24 @@ API reference
This page gives an overview of all public pandas objects, functions and
methods. All classes and functions exposed in ``pandas.*`` namespace are public.

Some subpackages are public which include ``pandas.errors``,
``pandas.plotting``, and ``pandas.testing``. Public functions in
``pandas.io`` and ``pandas.tseries`` submodules are mentioned in
the documentation. ``pandas.api.types`` subpackage holds some
public functions related to data types in pandas.
The following subpackages are public.

- ``pandas.errors``: Custom exception and warnings classes that are raised by pandas.
- ``pandas.plotting``: Plotting public API.
- ``pandas.testing``: Functions that are useful for writing tests involving pandas objects.
- ``pandas.api.extensions``: Functions and classes for extending pandas objects.
- ``pandas.api.indexers``: Functions and classes for rolling window indexers.
- ``pandas.api.interchange``: DataFrame interchange protocol.
- ``pandas.api.types``: Datatype classes and functions.
- ``pandas.api.typing``: Classes that may be necessary for type-hinting. These are
classes that are encountered as intermediates results but should not be
instantiated directly by users. These classes are not to be confused with
classes from the `pandas-stubs <https://github.com/pandas-dev/pandas-stubs>`_
package which has classes in addition to those that occur in pandas for type-hinting.

In addition, public functions in ``pandas.io`` and ``pandas.tseries`` submodules
are mentioned in the documentation.


.. warning::

Expand Down
1 change: 1 addition & 0 deletions doc/source/whatsnew/v2.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ Other API changes
methods to get a full slice (for example ``df.loc[:]`` or ``df[:]``) (:issue:`49469`)
- Disallow computing ``cumprod`` for :class:`Timedelta` object; previously this returned incorrect values (:issue:`50246`)
- :func:`to_datetime` with ``unit`` of either "Y" or "M" will now raise if a sequence contains a non-round ``float`` value, matching the ``Timestamp`` behavior (:issue:`50301`)
- Classes that are useful for type-hinting have been added to the public API in the new submodule ``pandas.api.typing`` (:issue:`48577`)
-

.. ---------------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions pandas/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
indexers,
interchange,
types,
typing,
)

__all__ = [
"interchange",
"extensions",
"indexers",
"types",
"typing",
]
40 changes: 40 additions & 0 deletions pandas/api/typing/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""
Public API classes that store intermediate results useful for type-hinting.
"""

from pandas.core.groupby import (
DataFrameGroupBy,
SeriesGroupBy,
)
from pandas.core.resample import (
Resampler,
TimeGrouper,
)
from pandas.core.window import (
Expanding,
ExponentialMovingWindow,
Rolling,
Window,
)

from pandas.io.formats.style import Styler
from pandas.io.json._json import JsonReader
from pandas.io.stata import (
StataReader,
StataWriter,
)

__all__ = [
"DataFrameGroupBy",
Copy link
Member

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?

Copy link
Member Author

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.

"Expanding",
"ExponentialMovingWindow",
"JsonReader",
"Resampler",
"Rolling",
"SeriesGroupBy",
"StataWriter",
"StataReader",
"Styler",
"TimeGrouper",
"Window",
]
2 changes: 1 addition & 1 deletion pandas/tests/api/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def test_depr(self):


class TestApi(Base):
allowed = ["types", "extensions", "indexers", "interchange"]
allowed = ["types", "extensions", "indexers", "interchange", "typing"]

def test_api(self):
self.check(api, self.allowed)
Expand Down
1 change: 1 addition & 0 deletions pandas/tests/plotting/test_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def test_registry_mpl_resets():
code = (
"import matplotlib.units as units; "
"import matplotlib.dates as mdates; "
"import matplotlib.pyplot as plt; "
"n_conv = len(units.registry); "
"import pandas as pd; "
"pd.plotting.register_matplotlib_converters(); "
Expand Down