From ff34f01416dcc2aae9cbdafec48281a50fe62c91 Mon Sep 17 00:00:00 2001 From: Jeff Reback Date: Sun, 3 Jun 2018 18:34:22 -0400 Subject: [PATCH] small doc enhancements --- doc/source/extending.rst | 18 ++++++++++++++---- pandas/core/dtypes/dtypes.py | 4 ++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/doc/source/extending.rst b/doc/source/extending.rst index f665b219a7bd1d..56f0f79dd7fe3d 100644 --- a/doc/source/extending.rst +++ b/doc/source/extending.rst @@ -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` ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -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 @@ -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. diff --git a/pandas/core/dtypes/dtypes.py b/pandas/core/dtypes/dtypes.py index 7d147da661e34d..248d46e3ab9e03 100644 --- a/pandas/core/dtypes/dtypes.py +++ b/pandas/core/dtypes/dtypes.py @@ -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 = []