Skip to content

DOC: whatsnew & linked edits #24649

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 2 commits into from
Jan 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion doc/source/advanced.rst
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ If you need integer based selection, you should use ``iloc``:

dfir.iloc[0:5]

.. _advanced.intervallindex:
.. _advanced.intervalindex:

IntervalIndex
~~~~~~~~~~~~~
Expand Down
6 changes: 3 additions & 3 deletions doc/source/api/arrays.rst
Original file line number Diff line number Diff line change
Expand Up @@ -330,13 +330,13 @@ a :class:`pandas.api.types.CategoricalDtype`.
:toctree: generated/
:template: autosummary/class_without_autosummary.rst

api.types.CategoricalDtype
CategoricalDtype

.. autosummary::
:toctree: generated/

api.types.CategoricalDtype.categories
api.types.CategoricalDtype.ordered
CategoricalDtype.categories
CategoricalDtype.ordered

Categorical data can be stored in a :class:`pandas.Categorical`

Expand Down
18 changes: 10 additions & 8 deletions doc/source/basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,37 +64,37 @@ NumPy's type system to add support for custom arrays
(see :ref:`basics.dtypes`).

To get the actual data inside a :class:`Index` or :class:`Series`, use
the **array** property
the ``.array`` property

.. ipython:: python

s.array
s.index.array

:attr:`~Series.array` will always be an :class:`~pandas.api.extensions.ExtensionArray`.
The exact details of what an ``ExtensionArray`` is and why pandas uses them is a bit
The exact details of what an :class:`~pandas.api.extensions.ExtensionArray` is and why pandas uses them is a bit
beyond the scope of this introduction. See :ref:`basics.dtypes` for more.

If you know you need a NumPy array, use :meth:`~Series.to_numpy`
or :meth:`numpy.asarray`.
or :meth:`numpy.ndarray.asarray`.

.. ipython:: python

s.to_numpy()
np.asarray(s)

When the Series or Index is backed by
an :class:`~pandas.api.extension.ExtensionArray`, :meth:`~Series.to_numpy`
an :class:`~pandas.api.extensions.ExtensionArray`, :meth:`~Series.to_numpy`
may involve copying data and coercing values. See :ref:`basics.dtypes` for more.

:meth:`~Series.to_numpy` gives some control over the ``dtype`` of the
resulting :class:`ndarray`. For example, consider datetimes with timezones.
resulting :class:`numpy.ndarray`. For example, consider datetimes with timezones.
NumPy doesn't have a dtype to represent timezone-aware datetimes, so there
are two possibly useful representations:

1. An object-dtype :class:`ndarray` with :class:`Timestamp` objects, each
1. An object-dtype :class:`numpy.ndarray` with :class:`Timestamp` objects, each
with the correct ``tz``
2. A ``datetime64[ns]`` -dtype :class:`ndarray`, where the values have
2. A ``datetime64[ns]`` -dtype :class:`numpy.ndarray`, where the values have
been converted to UTC and the timezone discarded

Timezones may be preserved with ``dtype=object``
Expand All @@ -106,6 +106,8 @@ Timezones may be preserved with ``dtype=object``

Or thrown away with ``dtype='datetime64[ns]'``

.. ipython:: python

ser.to_numpy(dtype="datetime64[ns]")

Getting the "raw data" inside a :class:`DataFrame` is possibly a bit more
Expand Down Expand Up @@ -137,7 +139,7 @@ drawbacks:

1. When your Series contains an :ref:`extension type <extending.extension-types>`, it's
unclear whether :attr:`Series.values` returns a NumPy array or the extension array.
:attr:`Series.array` will always return an ``ExtensionArray``, and will never
:attr:`Series.array` will always return an :class:`~pandas.api.extensions.ExtensionArray`, and will never
copy data. :meth:`Series.to_numpy` will always return a NumPy array,
potentially at the cost of copying / coercing values.
2. When your DataFrame contains a mixture of data types, :attr:`DataFrame.values` may
Expand Down
Loading