Skip to content

Commit 708792a

Browse files
committed
DOC: cleanup of timeseries.rst
1 parent 24fb26d commit 708792a

File tree

1 file changed

+25
-18
lines changed

1 file changed

+25
-18
lines changed

doc/source/timeseries.rst

+25-18
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,8 @@ See :ref:`here <timeseries.oob>` for ways to represent data outside these bound.
358358

359359
.. _timeseries.datetimeindex:
360360

361-
DatetimeIndex
362-
-------------
361+
Indexing
362+
--------
363363

364364
One of the main uses for ``DatetimeIndex`` is as an index for pandas objects.
365365
The ``DatetimeIndex`` class contains many timeseries related optimizations:
@@ -399,8 +399,8 @@ intelligent functionality like selection, slicing, etc.
399399
400400
.. _timeseries.partialindexing:
401401

402-
DatetimeIndex Partial String Indexing
403-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
402+
Partial String Indexing
403+
~~~~~~~~~~~~~~~~~~~~~~~
404404

405405
You can pass in dates and strings that parse to dates as indexing parameters:
406406

@@ -478,7 +478,9 @@ DatetimeIndex Partial String Indexing also works on DataFrames with a ``MultiInd
478478
.. _timeseries.slice_vs_exact_match:
479479

480480
Slice vs. exact match
481-
^^^^^^^^^^^^^^^^^^^^^
481+
~~~~~~~~~~~~~~~~~~~~~
482+
483+
.. versionchanged:: 0.20.0
482484

483485
The same string used as an indexing parameter can be treated either as a slice or as an exact match depending on the resolution of an index. If the string is less accurate than the index, it will be treated as a slice, otherwise as an exact match.
484486

@@ -492,20 +494,20 @@ For example, let us consider ``Series`` object which index has minute resolution
492494
'2012-01-01 00:02:00']))
493495
series_minute.index.resolution
494496
495-
Timestamp string less accurate than minute gives ``Series`` object.
497+
A Timestamp string less accurate than a minute gives a ``Series`` object.
496498

497499
.. ipython:: python
498500
499501
series_minute['2011-12-31 23']
500502
501-
Timestamp string with minute resolution (or more accurate) gives scalar instead, i.e. it is not casted to a slice.
503+
A Timestamp string with minute resolution (or more accurate), gives a scalar instead, i.e. it is not casted to a slice.
502504

503505
.. ipython:: python
504506
505507
series_minute['2011-12-31 23:59']
506508
series_minute['2011-12-31 23:59:00']
507509
508-
If index resolution is second, the minute-accurate timestamp gives ``Series``.
510+
If index resolution is second, then, the minute-accurate timestamp gives a ``Series``.
509511

510512
.. ipython:: python
511513
@@ -524,13 +526,16 @@ If the timestamp string is treated as a slice, it can be used to index ``DataFra
524526
index=series_minute.index)
525527
dft_minute['2011-12-31 23']
526528
527-
However if the string is treated as an exact match the selection in ``DataFrame``'s ``[]`` will be column-wise and not row-wise, see :ref:`Indexing Basics <indexing.basics>`. For example ``dft_minute['2011-12-31 23:59']`` will raise ``KeyError`` as ``'2012-12-31 23:59'`` has the same resolution as index and there is no column with such name:
528529
529-
To select a single row, use ``.loc``.
530+
:: warning:
530531

531-
.. ipython:: python
532+
However if the string is treated as an exact match the selection in ``DataFrame``'s ``[]`` will be column-wise and not row-wise, see :ref:`Indexing Basics <indexing.basics>`. For example ``dft_minute['2011-12-31 23:59']`` will raise ``KeyError`` as ``'2012-12-31 23:59'`` has the same resolution as index and there is no column with such name:
533+
534+
To select a single row, use ``.loc``.
535+
536+
.. ipython:: python
532537
533-
dft_minute.loc['2011-12-31 23:59']
538+
dft_minute.loc['2011-12-31 23:59']
534539
535540
Note also that ``DatetimeIndex`` resolution cannot be less precise than day.
536541

@@ -544,12 +549,12 @@ Note also that ``DatetimeIndex`` resolution cannot be less precise than day.
544549
series_monthly['2011-12'] # returns Series
545550
546551
547-
Datetime Indexing
548-
~~~~~~~~~~~~~~~~~
552+
Exact Indexing
553+
~~~~~~~~~~~~~~
549554

550-
As discussed in previous section, indexing a ``DateTimeIndex`` with a partial string depends on the "accuracy" of the period, in other words how specific the interval is in relation to the resolution of the index. In contrast, indexing with datetime objects is exact, because the objects have exact meaning. These also follow the semantics of *including both endpoints*.
555+
As discussed in previous section, indexing a ``DateTimeIndex`` with a partial string depends on the "accuracy" of the period, in other words how specific the interval is in relation to the resolution of the index. In contrast, indexing with ``Timestamp`` or ``datetime`` objects is exact, because the objects have exact meaning. These also follow the semantics of *including both endpoints*.
551556

552-
These ``datetime`` objects are specific ``hours, minutes,`` and ``seconds`` even though they were not explicitly specified (they are ``0``).
557+
These ``Timestamp`` and ``datetime`` objects have exact ``hours, minutes,`` and ``seconds``, even though they were not explicitly specified (they are ``0``).
553558

554559
.. ipython:: python
555560
@@ -578,10 +583,10 @@ regularity will result in a ``DatetimeIndex`` (but frequency is lost):
578583
579584
ts[[0, 2, 6]].index
580585
581-
.. _timeseries.offsets:
586+
.. _timeseries.components:
582587

583588
Time/Date Components
584-
~~~~~~~~~~~~~~~~~~~~~~~~~~~
589+
--------------------
585590

586591
There are several time/date properties that one can access from ``Timestamp`` or a collection of timestamps like a ``DateTimeIndex``.
587592

@@ -617,6 +622,8 @@ There are several time/date properties that one can access from ``Timestamp`` or
617622

618623
Furthermore, if you have a ``Series`` with datetimelike values, then you can access these properties via the ``.dt`` accessor, see the :ref:`docs <basics.dt_accessors>`
619624

625+
.. _timeseries.offsets:
626+
620627
DateOffset objects
621628
------------------
622629

0 commit comments

Comments
 (0)