Skip to content

Commit ea91291

Browse files
committed
API: Add pandas.api.typing
1 parent d859ecc commit ea91291

File tree

5 files changed

+62
-6
lines changed

5 files changed

+62
-6
lines changed

doc/source/reference/index.rst

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,24 @@ API reference
99
This page gives an overview of all public pandas objects, functions and
1010
methods. All classes and functions exposed in ``pandas.*`` namespace are public.
1111

12-
Some subpackages are public which include ``pandas.errors``,
13-
``pandas.plotting``, and ``pandas.testing``. Public functions in
14-
``pandas.io`` and ``pandas.tseries`` submodules are mentioned in
15-
the documentation. ``pandas.api.types`` subpackage holds some
16-
public functions related to data types in pandas.
12+
The following subpackages are public.
13+
14+
- ``pandas.errors``: Custom exception and warnings classes that are raised by pandas.
15+
- ``pandas.plotting``: Plotting public API.
16+
- ``pandas.testing``: Functions that are useful for writing tests involving pandas objects.
17+
- ``pandas.api.extensions``: Functions and classes for extending pandas objects.
18+
- ``pandas.api.indexers``: Functions and classes for rolling window indexers.
19+
- ``pandas.api.interchange``: DataFrame interchange protocol.
20+
- ``pandas.api.types``: Datatype classes and functions.
21+
- ``pandas.api.typing``: Classes that may be necessary for type-hinting. These are
22+
classes that are encountered as intermediates results but should not be
23+
instantiated directly by users. These classes are not to be confused with
24+
classes from the `pandas-stubs <https://github.com/pandas-dev/pandas-stubs>`_
25+
package which has classes in addition to those that occur in pandas for type-hinting.
26+
27+
In addition, public functions in ``pandas.io`` and ``pandas.tseries`` submodules
28+
are mentioned in the documentation.
29+
1730

1831
.. warning::
1932

doc/source/whatsnew/v2.0.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,7 @@ Other API changes
497497
methods to get a full slice (for example ``df.loc[:]`` or ``df[:]``) (:issue:`49469`)
498498
- Disallow computing ``cumprod`` for :class:`Timedelta` object; previously this returned incorrect values (:issue:`50246`)
499499
- :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`)
500+
- :class:`DataFrameGroupBy` and :class:`SeriesGroupBy` have been added to ``pandas.api.typing`` (:issue:`48577`)
500501
-
501502

502503
.. ---------------------------------------------------------------------------

pandas/api/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
indexers,
55
interchange,
66
types,
7+
typing,
78
)
89

910
__all__ = [
1011
"interchange",
1112
"extensions",
1213
"indexers",
1314
"types",
15+
"typing",
1416
]

pandas/api/typing/__init__.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
"""
2+
Public API classes that store intermediate results useful for type-hinting.
3+
"""
4+
5+
from pandas.core.groupby import (
6+
DataFrameGroupBy,
7+
SeriesGroupBy,
8+
)
9+
from pandas.core.resample import (
10+
Resampler,
11+
TimeGrouper,
12+
)
13+
from pandas.core.window import (
14+
Expanding,
15+
ExponentialMovingWindow,
16+
Rolling,
17+
Window,
18+
)
19+
20+
from pandas.io.formats.style import Styler
21+
from pandas.io.json._json import JsonReader
22+
from pandas.io.stata import (
23+
StataReader,
24+
StataWriter,
25+
)
26+
27+
__all__ = [
28+
"DataFrameGroupBy",
29+
"Expanding",
30+
"ExponentialMovingWindow",
31+
"JsonReader",
32+
"Resampler",
33+
"Rolling",
34+
"SeriesGroupBy",
35+
"StataWriter",
36+
"StataReader",
37+
"Styler",
38+
"TimeGrouper",
39+
"Window",
40+
]

pandas/tests/api/test_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def test_depr(self):
235235

236236

237237
class TestApi(Base):
238-
allowed = ["types", "extensions", "indexers", "interchange"]
238+
allowed = ["types", "extensions", "indexers", "interchange", "typing"]
239239

240240
def test_api(self):
241241
self.check(api, self.allowed)

0 commit comments

Comments
 (0)