Skip to content

Commit dbb1048

Browse files
committed
DOC: Various EA docs
Closes pandas-dev#20668
1 parent 0bd8a5a commit dbb1048

File tree

4 files changed

+41
-8
lines changed

4 files changed

+41
-8
lines changed

doc/source/extending.rst

+25
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ If you write a custom accessor, make a pull request adding it to our
5757
Extension Types
5858
---------------
5959

60+
.. versionadded:: 0.23.0
61+
62+
.. warning::
63+
64+
The ``ExtensionDtype`` and ``ExtensionArray`` APIs are new and
65+
experimental. They may change between versions without warning.
66+
6067
Pandas defines an interface for implementing data types and arrays that *extend*
6168
NumPy's type system. Pandas itself uses the extension system for some types
6269
that aren't built into NumPy (categorical, period, interval, datetime with
@@ -106,6 +113,24 @@ by some other storage type, like Python lists.
106113
See the `extension array source`_ for the interface definition. The docstrings
107114
and comments contain guidance for properly implementing the interface.
108115

116+
We provide a test suite for ensuring that your extension arrays satisfy the expected
117+
behavior. To use the test-suite, you must provide several pytest fixtures and inherit
118+
from the base test class. The required fixtures are found in
119+
https://github.com/pandas-dev/pandas/blob/master/pandas/tests/extension/conftest.py.
120+
121+
To use a test, subclass it
122+
123+
.. code-block:: python
124+
125+
from pandas.tests.extension import base
126+
127+
class TestConstructors(base.BaseConstructorsTests):
128+
pass
129+
130+
131+
See https://github.com/pandas-dev/pandas/blob/master/pandas/tests/extension/base/__init__.py
132+
for a list of all the tests available.
133+
109134
.. _extension dtype source: https://github.com/pandas-dev/pandas/blob/master/pandas/core/dtypes/base.py
110135
.. _extension array source: https://github.com/pandas-dev/pandas/blob/master/pandas/core/arrays/base.py
111136

doc/source/install.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Instructions for installing from source,
1515
`PyPI <http://pypi.python.org/pypi/pandas>`__, `ActivePython <https://www.activestate.com/activepython/downloads>`__, various Linux distributions, or a
1616
`development version <http://github.com/pandas-dev/pandas>`__ are also provided.
1717

18-
.. _install.dropping_27:
18+
.. _install.dropping-27:
1919

2020
Plan for dropping Python 2.7
2121
----------------------------

doc/source/whatsnew/v0.23.0.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ version.
1111
.. warning::
1212

1313
Starting January 1, 2019, pandas feature releases will support Python 3 only.
14-
See :ref:`here <install.dropping_27>` for more.
14+
See :ref:`install.dropping-27` for more.
1515

1616
.. _whatsnew_0230.enhancements:
1717

@@ -306,8 +306,8 @@ Supplying a ``CategoricalDtype`` will make the categories in each column consist
306306

307307
.. _whatsnew_023.enhancements.extension:
308308

309-
Extending Pandas with Custom Types
310-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
309+
Extending Pandas with Custom Types (Experimental)
310+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
311311

312312
Pandas now supports storing array-like objects that aren't necessarily 1-D NumPy
313313
arrays as columns in a DataFrame or values in a Series. This allows third-party

pandas/core/arrays/base.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@ class ExtensionArray(object):
1414
with a custom type and will not attempt to coerce them to objects. They
1515
may be stored directly inside a :class:`DataFrame` or :class:`Series`.
1616
17+
.. versionadded:: 0.23.0
18+
1719
Notes
1820
-----
1921
The interface includes the following abstract methods that must be
2022
implemented by subclasses:
2123
2224
* _constructor_from_sequence
25+
* _from_factorized
2326
* __getitem__
2427
* __len__
2528
* dtype
@@ -35,6 +38,15 @@ class ExtensionArray(object):
3538
* _can_hold_na
3639
* _formatting_values
3740
41+
Some methods require casting the ExtensionArray to an ndarray of Python
42+
objects, which may be expensive. When performance is a concern, we highly
43+
recommend overriding the following methods.
44+
45+
* fillna
46+
* unique
47+
* factorize / _values_for_factorize
48+
* argsort / _values_for_argsort
49+
3850
This class does not inherit from 'abc.ABCMeta' for performance reasons.
3951
Methods and properties required by the interface raise
4052
``pandas.errors.AbstractMethodError`` and no ``register`` method is
@@ -50,10 +62,6 @@ class ExtensionArray(object):
5062
by some other storage type, like Python lists. Pandas makes no
5163
assumptions on how the data are stored, just that it can be converted
5264
to a NumPy array.
53-
54-
Extension arrays should be able to be constructed with instances of
55-
the class, i.e. ``ExtensionArray(extension_array)`` should return
56-
an instance, not error.
5765
"""
5866
# '_typ' is for pandas.core.dtypes.generic.ABCExtensionArray.
5967
# Don't override this.

0 commit comments

Comments
 (0)