From d3d385c60598b5b94b71e250dbbc110b7fd84f83 Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Thu, 29 Mar 2018 06:23:28 -0500 Subject: [PATCH 1/4] DOC: Fixups * /tmp/doc/source/api.rst:2551: WARNING: toctree contains reference to nonexisting document 'generated/pandas.Timestamp.offset' * /home/travis/build/pandas-dev/pandas/pandas/core/series.py:docstring of pandas.Series.asobject:6: WARNING: Inline literal start-string without end-string. * /tmp/doc/source/io.rst:2265: WARNING: Unknown target name: "level". * /tmp/doc/source/overview.rst:123: WARNING: Include file '/tmp/LICENSE' not found or reading it failed # Please enter the commit message for your changes. Lines starting --- ci/build_docs.sh | 1 + doc/source/api.rst | 1 - doc/source/io.rst | 2 +- pandas/core/series.py | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ci/build_docs.sh b/ci/build_docs.sh index 5de9e158bcdb6..90a666dc34ed7 100755 --- a/ci/build_docs.sh +++ b/ci/build_docs.sh @@ -24,6 +24,7 @@ if [ "$DOC" ]; then source activate pandas mv "$TRAVIS_BUILD_DIR"/doc /tmp + mv "$TRAVIS_BUILD_DIR/LICENSE" /tmp # included in the docs. cd /tmp/doc echo ############################### diff --git a/doc/source/api.rst b/doc/source/api.rst index a5d24302e69e2..5e794c11658e8 100644 --- a/doc/source/api.rst +++ b/doc/source/api.rst @@ -2576,4 +2576,3 @@ objects. generated/pandas.Series.ix generated/pandas.Series.imag generated/pandas.Series.real - generated/pandas.Timestamp.offset diff --git a/doc/source/io.rst b/doc/source/io.rst index 68b431925d983..ff505f525fc22 100644 --- a/doc/source/io.rst +++ b/doc/source/io.rst @@ -2263,7 +2263,7 @@ round-trippable manner. new_df.dtypes Please note that the literal string 'index' as the name of an :class:`Index` -is not round-trippable, nor are any names beginning with 'level_' within a +is not round-trippable, nor are any names beginning with ``'level_'`` within a :class:`MultiIndex`. These are used by default in :func:`DataFrame.to_json` to indicate missing values and the subsequent read cannot distinguish the intent. diff --git a/pandas/core/series.py b/pandas/core/series.py index 89075e5e6acbb..30e0319346961 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -468,7 +468,7 @@ def asobject(self): .. deprecated :: 0.23.0 - Use ``astype(object) instead. + Use ``astype(object)`` instead. *this is an internal non-public method* """ From b867248a4ad8b183a32ae48e3459fbdae351c0c8 Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Thu, 29 Mar 2018 06:34:26 -0500 Subject: [PATCH 2/4] Anonymous hyperlink --- doc/source/timeseries.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/source/timeseries.rst b/doc/source/timeseries.rst index 86cff4a358975..adb4cdf2974a0 100644 --- a/doc/source/timeseries.rst +++ b/doc/source/timeseries.rst @@ -198,8 +198,9 @@ This could also potentially speed up the conversion considerably. pd.to_datetime('12-11-2010 00:00', format='%d-%m-%Y %H:%M') For more information on the choices available when specifying the ``format`` -option, see the Python `datetime documentation - Date: Thu, 29 Mar 2018 07:09:57 -0500 Subject: [PATCH 3/4] DOC: Added ExtensionArray whatsnew --- doc/source/whatsnew/v0.23.0.txt | 55 +++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/doc/source/whatsnew/v0.23.0.txt b/doc/source/whatsnew/v0.23.0.txt index c6dadb7589869..69b2db4b28722 100644 --- a/doc/source/whatsnew/v0.23.0.txt +++ b/doc/source/whatsnew/v0.23.0.txt @@ -299,6 +299,61 @@ Supplying a ``CategoricalDtype`` will make the categories in each column consist df['A'].dtype df['B'].dtype +Extension Types +^^^^^^^^^^^^^^^ + +Pandas now supports storing array-like objects that aren't necessarily 1-D NumPy +arrays as columns in a DataFrame or values in a Series. This allows third-party +libraries to implement extensions to NumPy's types, similar to how pandas +implemented categoricals, datetimes with timezones, periods, and intervals. + +As a demonstration, we'll use cyberpandas_, which provides an ``IPArray`` type +for storing ip addresses. + +.. code-block:: ipython + + In [1]: import pandas as pd; from cyberpandas import IPArray + + In [2]: values = IPArray([ + ...: 0, + ...: 3232235777, + ...: 42540766452641154071740215577757643572 + ...: ]) + ...: + ...: + +``IPArray`` isn't a normal 1-D NumPy array, but because it's a pandas +ExtensionArray, it can be stored properly inside pandas' containers. + +.. code-block:: ipython + + In [3]: ser = pd.Series(values) + ...: + + In [4]: ser + Out[4]: + 0 0.0.0.0 + 1 192.168.1.1 + 2 2001:db8:85a3::8a2e:370:7334 + dtype: ip + +Notice that the dtype is ``ip``. The missing value semantics of the underlying +array are respected: + + In [5]: ser.isna() + ...: + Out[5]: + 0 True + 1 False + 2 False + dtype: bool + +For more, see the :ref:`extension types ` +documentation. If you build an extension array, publicize it on our +:ref:`ecosystem page `. + +.. _cyberpandas: https://cyberpandas.readthedocs.io/en/latest/ + .. _whatsnew_0230.enhancements.other: Other Enhancements From e74d0f62c789f39b59e2c4018ad966f5b1d0f2f1 Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Thu, 29 Mar 2018 09:05:35 -0500 Subject: [PATCH 4/4] fixup! DOC: Added ExtensionArray whatsnew --- doc/source/whatsnew/v0.23.0.txt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/doc/source/whatsnew/v0.23.0.txt b/doc/source/whatsnew/v0.23.0.txt index 69b2db4b28722..e83f149db1f18 100644 --- a/doc/source/whatsnew/v0.23.0.txt +++ b/doc/source/whatsnew/v0.23.0.txt @@ -299,8 +299,10 @@ Supplying a ``CategoricalDtype`` will make the categories in each column consist df['A'].dtype df['B'].dtype -Extension Types -^^^^^^^^^^^^^^^ +.. _whatsnew_023.enhancements.extension: + +Extending Pandas with Custom Types +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Pandas now supports storing array-like objects that aren't necessarily 1-D NumPy arrays as columns in a DataFrame or values in a Series. This allows third-party @@ -312,7 +314,7 @@ for storing ip addresses. .. code-block:: ipython - In [1]: import pandas as pd; from cyberpandas import IPArray + In [1]: from cyberpandas import IPArray In [2]: values = IPArray([ ...: 0, @@ -323,7 +325,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. +``ExtensionArray``, it can be stored properly inside pandas' containers. .. code-block:: ipython