Skip to content

Commit e28680b

Browse files
committed
DOC: fix up docs a bit for datetime64[ns, tz]
1 parent 81b647f commit e28680b

File tree

2 files changed

+41
-15
lines changed

2 files changed

+41
-15
lines changed

doc/source/timeseries.rst

+34-11
Original file line numberDiff line numberDiff line change
@@ -1753,22 +1753,45 @@ TZ aware Dtypes
17531753

17541754
.. versionadded:: 0.17.0
17551755

1756-
``Series/DatetimeIndex`` with a timezone naive value are represented with a dtype of ``datetime64[ns]``.
1756+
``Series/DatetimeIndex`` with a timezone **naive** value are represented with a dtype of ``datetime64[ns]``.
17571757

17581758
.. ipython:: python
17591759
1760-
dr = pd.date_range('20130101',periods=3)
1761-
dr
1762-
s = Series(dr)
1763-
s
1760+
dr_naive = pd.date_range('20130101',periods=3)
1761+
dr_naive
1762+
s_naive = Series(dr_naive)
1763+
s_naive
17641764
1765-
``Series/DatetimeIndex`` with a timezone aware value are represented with a dtype of ``datetime64[ns, tz]``.
1765+
``Series/DatetimeIndex`` with a timezone **aware** value are represented with a dtype of ``datetime64[ns, tz]``.
17661766

17671767
.. ipython:: python
17681768
1769-
dr = pd.date_range('20130101',periods=3,tz='US/Eastern')
1770-
dr
1771-
s = Series(dr)
1772-
s
1769+
dr_aware = pd.date_range('20130101',periods=3,tz='US/Eastern')
1770+
dr_aware
1771+
s_aware = Series(dr_aware)
1772+
s_aware
1773+
1774+
Both of these ``Series`` can be manipulated via the ``.dt`` accessor, see :ref:`here <basics.dt_accessors>`.
1775+
See the :ref:`docs <timeseries.dtypes>` for more details.
1776+
1777+
.. note::
1778+
1779+
Using the ``.values`` accessor on a ``Series``, returns an numpy array of the data.
1780+
These values are converted to UTC, as numpy does not currently support timezones (even though it is *printing* in the local timezone!).
1781+
1782+
.. ipython:: python
1783+
1784+
s_naive.values
1785+
s_aware.values
1786+
1787+
Further note that once converted to a numpy array these would lose the tz tenor.
1788+
1789+
.. ipython:: python
1790+
1791+
Series(s_aware.values)
1792+
1793+
However, these can be easily converted
1794+
1795+
.. ipython:: python
17731796
1774-
Both of these ``Series`` can be manipulated via the ``.dt`` accessor, see the :ref:`docs <basics.dt_accessors>` as well.
1797+
Series(s_aware).dt.tz_localize('UTC').dt.tz_convert('US/Eastern')

doc/source/whatsnew/v0.17.0.txt

+7-4
Original file line numberDiff line numberDiff line change
@@ -447,9 +447,9 @@ Datetime with TZ
447447

448448
We are adding an implementation that natively supports datetime with timezones. A ``Series`` or a ``DataFrame`` column previously
449449
*could* be assigned a datetime with timezones, and would work as an ``object`` dtype. This had performance issues with a large
450-
number rows. (:issue:`8260`, :issue:`10763`)
450+
number rows. See the :ref:`docs <timeseries.timezone_series>` for more details. (:issue:`8260`, :issue:`10763`).
451451

452-
The new implementation allows for having a single-timezone across all rows, and operating on it in a performant manner.
452+
The new implementation allows for having a single-timezone across all rows, with operations in a performant manner.
453453

454454
.. ipython:: python
455455

@@ -469,13 +469,15 @@ This uses a new-dtype representation as well, that is very similar in look-and-f
469469
.. ipython:: python
470470

471471
df['B'].dtype
472-
type(df['B']).dtype
472+
type(df['B'].dtype)
473473

474474
.. note::
475475

476476
There is a slightly different string repr for the underlying ``DatetimeIndex`` as a result of the dtype changes, but
477477
functionally these are the same.
478478

479+
Previous Behavior:
480+
479481
.. code-block:: python
480482

481483
In [1]: pd.date_range('20130101',periods=3,tz='US/Eastern')
@@ -486,12 +488,13 @@ This uses a new-dtype representation as well, that is very similar in look-and-f
486488
In [2]: pd.date_range('20130101',periods=3,tz='US/Eastern').dtype
487489
Out[2]: dtype('<M8[ns]')
488490

491+
New Behavior:
492+
489493
.. ipython:: python
490494

491495
pd.date_range('20130101',periods=3,tz='US/Eastern')
492496
pd.date_range('20130101',periods=3,tz='US/Eastern').dtype
493497

494-
495498
.. _whatsnew_0170.api_breaking.convert_objects:
496499

497500
Changes to convert_objects

0 commit comments

Comments
 (0)