8000 ENH: add in extension dtype registry by jreback · Pull Request #21185 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

ENH: add in extension dtype registry #21185

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 22 commits into from
Jul 3, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
small doc enhancements
  • Loading branch information
jreback committed Jun 29, 2018
commit 07d10382a71e63b1f4d183936ce7211a45b922d4
18 changes: 14 additions & 4 deletions doc/source/extending.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@ extension array for IP Address data, this might be ``ipaddress.IPv4Address``.

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

.. versionadded:: 0.24.0

:class:`pandas.api.extension.ExtensionDtype` can be registered to pandas to allow creation via a string dtype name.
This allows one to instantiate ``Series`` and ``.astype()`` with a registered string name, for
example ``'category'`` is a registered string accessor for the ``CategoricalDtype``.

See the `extension dtype dtypes`_ for more on how to register dtypes.


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

Expand Down Expand Up @@ -131,6 +140,7 @@ To use a test, subclass it:
See https://github.com/pandas-dev/pandas/blob/master/pandas/tests/extension/base/__init__.py
for a list of all the tests available.

.. _extension dtype dtypes: https://github.com/pandas-dev/pandas/blob/master/pandas/core/dtypes/dtypes.py
.. _extension dtype source: https://github.com/pandas-dev/pandas/blob/master/pandas/core/dtypes/base.py
.. _extension array source: https://github.com/pandas-dev/pandas/blob/master/pandas/core/arrays/base.py

Expand Down Expand Up @@ -174,11 +184,11 @@ There are 3 constructor properties to be defined:
Following table shows how ``pandas`` data structures define constructor properties by default.

=========================== ======================= =============
Property Attributes ``Series`` ``DataFrame``
Property Attributes ``Series`` ``DataFrame``
=========================== ======================= =============
``_constructor`` ``Series`` ``DataFrame``
``_constructor_sliced`` ``NotImplementedError`` ``Series``
``_constructor_expanddim`` ``DataFrame`` ``Panel``
``_constructor`` ``Series`` ``DataFrame``
``_constructor_sliced`` ``NotImplementedError`` ``Series``
``_constructor_expanddim`` ``DataFrame`` ``Panel``
=========================== ======================= =============

Below example shows how to define ``SubclassedSeries`` and ``SubclassedDataFrame`` overriding constructor properties.
Expand Down
4 changes: 4 additions & 0 deletions pandas/core/dtypes/dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ class Registry(object):
to try inference from a string or a dtype class

These are tried in order for inference.

Examples
--------
registry.register(MyExtensionDtype)
"""
dtypes = []

Expand Down
0