Skip to content

Commit 3f3e92f

Browse files
TomAugspurgerjorisvandenbossche
authored andcommitted
DOC/API: expose ExtensionArray in public api (#20795)
1 parent f89c25d commit 3f3e92f

File tree

6 files changed

+14
-10
lines changed

6 files changed

+14
-10
lines changed

doc/source/api.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2549,6 +2549,8 @@ objects.
25492549
api.extensions.register_dataframe_accessor
25502550
api.extensions.register_series_accessor
25512551
api.extensions.register_index_accessor
2552+
api.extensions.ExtensionDtype
2553+
api.extensions.ExtensionArray
25522554

25532555
.. This is to prevent warnings in the doc build. We don't want to encourage
25542556
.. these methods.

doc/source/extending.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Extension Types
6161

6262
.. warning::
6363

64-
The ``ExtensionDtype`` and ``ExtensionArray`` APIs are new and
64+
The :class:`pandas.api.extension.ExtensionDtype` and :class:`pandas.api.extension.ExtensionArray` APIs are new and
6565
experimental. They may change between versions without warning.
6666

6767
Pandas defines an interface for implementing data types and arrays that *extend*
@@ -79,10 +79,10 @@ on :ref:`ecosystem.extensions`.
7979

8080
The interface consists of two classes.
8181

82-
``ExtensionDtype``
83-
^^^^^^^^^^^^^^^^^^
82+
:class:`~pandas.api.extension.ExtensionDtype`
83+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8484

85-
An ``ExtensionDtype`` is similar to a ``numpy.dtype`` object. It describes the
85+
A :class:`pandas.api.extension.ExtensionDtype` is similar to a ``numpy.dtype`` object. It describes the
8686
data type. Implementors are responsible for a few unique items like the name.
8787

8888
One particularly important item is the ``type`` property. This should be the
@@ -91,8 +91,8 @@ extension array for IP Address data, this might be ``ipaddress.IPv4Address``.
9191

9292
See the `extension dtype source`_ for interface definition.
9393

94-
``ExtensionArray``
95-
^^^^^^^^^^^^^^^^^^
94+
:class:`~pandas.api.extension.ExtensionArray`
95+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9696

9797
This class provides all the array-like functionality. ExtensionArrays are
9898
limited to 1 dimension. An ExtensionArray is linked to an ExtensionDtype via the

doc/source/whatsnew/v0.23.0.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ for storing ip addresses.
365365
...:
366366

367367
``IPArray`` isn't a normal 1-D NumPy array, but because it's a pandas
368-
``ExtensionArray``, it can be stored properly inside pandas' containers.
368+
:ref:`~pandas.api.extension.ExtensionArray, it can be stored properly inside pandas' containers.
369369

370370
.. code-block:: ipython
371371

pandas/api/extensions/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
from pandas.core.accessor import (register_dataframe_accessor, # noqa
33
register_index_accessor,
44
register_series_accessor)
5+
from pandas.core.arrays.base import ExtensionArray # noqa
6+
from pandas.core.dtypes.dtypes import ExtensionDtype # noqa

pandas/core/arrays/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ def dtype(self):
222222
@property
223223
def shape(self):
224224
# type: () -> Tuple[int, ...]
225+
"""Return a tuple of the array dimensions."""
225226
return (len(self),)
226227

227228
@property

pandas/core/common.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@
1414
from pandas.compat import long, zip, iteritems, PY36, OrderedDict
1515
from pandas.core.config import get_option
1616
from pandas.core.dtypes.generic import ABCSeries, ABCIndex
17-
from pandas.core.dtypes.common import _NS_DTYPE
17+
from pandas.core.dtypes.common import _NS_DTYPE, is_integer
1818
from pandas.core.dtypes.inference import _iterable_not_string
1919
from pandas.core.dtypes.missing import isna, isnull, notnull # noqa
20-
from pandas.api import types
2120
from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike
2221

2322

@@ -570,7 +569,7 @@ def _random_state(state=None):
570569
np.random.RandomState
571570
"""
572571

573-
if types.is_integer(state):
572+
if is_integer(state):
574573
return np.random.RandomState(state)
575574
elif isinstance(state, np.random.RandomState):
576575
return state

0 commit comments

Comments
 (0)