Skip to content

Commit ff34f01

Browse files
committed
small doc enhancements
1 parent 9e818b0 commit ff34f01

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

doc/source/extending.rst

+14-4
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,15 @@ extension array for IP Address data, this might be ``ipaddress.IPv4Address``.
9191

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

94+
.. versionadded:: 0.24.0
95+
96+
:class:`pandas.api.extension.ExtensionDtype` can be registered to pandas to allow creation via a string dtype name.
97+
This allows one to instantiate ``Series`` and ``.astype()`` with a registered string name, for
98+
example ``'category'`` is a registered string accessor for the ``CategoricalDtype``.
99+
100+
See the `extension dtype dtypes`_ for more on how to register dtypes.
101+
102+
94103
:class:`~pandas.api.extension.ExtensionArray`
95104
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
96105

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

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

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

176186
=========================== ======================= =============
177-
Property Attributes ``Series`` ``DataFrame``
187+
Property Attributes ``Series`` ``DataFrame``
178188
=========================== ======================= =============
179-
``_constructor`` ``Series`` ``DataFrame``
180-
``_constructor_sliced`` ``NotImplementedError`` ``Series``
181-
``_constructor_expanddim`` ``DataFrame`` ``Panel``
189+
``_constructor`` ``Series`` ``DataFrame``
190+
``_constructor_sliced`` ``NotImplementedError`` ``Series``
191+
``_constructor_expanddim`` ``DataFrame`` ``Panel``
182192
=========================== ======================= =============
183193

184194
Below example shows how to define ``SubclassedSeries`` and ``SubclassedDataFrame`` overriding constructor properties.

pandas/core/dtypes/dtypes.py

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ class Registry(object):
1616
to try inference from a string or a dtype class
1717
1818
These are tried in order for inference.
19+
20+
Examples
21+
--------
22+
registry.register(MyExtensionDtype)
1923
"""
2024
dtypes = []
2125

0 commit comments

Comments
 (0)