Skip to content

DOC/API: expose ExtensionArray in public api #20795

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 5 commits into from
Apr 24, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
2 changes: 2 additions & 0 deletions doc/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2549,6 +2549,8 @@ objects.
api.extensions.register_dataframe_accessor
api.extensions.register_series_accessor
api.extensions.register_index_accessor
api.extensions.ExtensionDtype
api.extensions.ExtensionArray

.. This is to prevent warnings in the doc build. We don't want to encourage
.. these methods.
Expand Down
12 changes: 6 additions & 6 deletions doc/source/extending.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Extension Types

.. warning::

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

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

The interface consists of two classes.

``ExtensionDtype``
^^^^^^^^^^^^^^^^^^
:class:`pandas.api.extension.ExtensionDtype`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add a ~ in the title link (to only show ExtensionDtype), or in the link in the text. (using the full link once is enough I think?)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

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

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

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

``ExtensionArray``
^^^^^^^^^^^^^^^^^^
:class:`pandas.api.extension.ExtensionArray`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This class provides all the array-like functionality. ExtensionArrays are
limited to 1 dimension. An ExtensionArray is linked to an ExtensionDtype via the
Expand Down
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v0.23.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ for storing ip addresses.
...:

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

.. code-block:: ipython

Expand Down
2 changes: 2 additions & 0 deletions pandas/api/extensions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
from pandas.core.accessor import (register_dataframe_accessor, # noqa
register_index_accessor,
register_series_accessor)
from pandas.core.arrays.base import ExtensionArray # noqa
from pandas.core.dtypes.dtypes import ExtensionDtype # noqa
5 changes: 2 additions & 3 deletions pandas/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@
from pandas.compat import long, zip, iteritems, PY36, OrderedDict
from pandas.core.config import get_option
from pandas.core.dtypes.generic import ABCSeries, ABCIndex
from pandas.core.dtypes.common import _NS_DTYPE
from pandas.core.dtypes.common import _NS_DTYPE, is_integer
from pandas.core.dtypes.inference import _iterable_not_string
from pandas.core.dtypes.missing import isna, isnull, notnull # noqa
from pandas.api import types
from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike


Expand Down Expand Up @@ -570,7 +569,7 @@ def _random_state(state=None):
np.random.RandomState
"""

if types.is_integer(state):
if is_integer(state):
return np.random.RandomState(state)
elif isinstance(state, np.random.RandomState):
return state
Expand Down