You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/source/timeseries.rst
+25-18
Original file line number
Diff line number
Diff line change
@@ -358,8 +358,8 @@ See :ref:`here <timeseries.oob>` for ways to represent data outside these bound.
358
358
359
359
.. _timeseries.datetimeindex:
360
360
361
-
DatetimeIndex
362
-
-------------
361
+
Indexing
362
+
--------
363
363
364
364
One of the main uses for ``DatetimeIndex`` is as an index for pandas objects.
365
365
The ``DatetimeIndex`` class contains many timeseries related optimizations:
@@ -399,8 +399,8 @@ intelligent functionality like selection, slicing, etc.
399
399
400
400
.. _timeseries.partialindexing:
401
401
402
-
DatetimeIndex Partial String Indexing
403
-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
402
+
Partial String Indexing
403
+
~~~~~~~~~~~~~~~~~~~~~~~
404
404
405
405
You can pass in dates and strings that parse to dates as indexing parameters:
406
406
@@ -478,7 +478,9 @@ DatetimeIndex Partial String Indexing also works on DataFrames with a ``MultiInd
478
478
.. _timeseries.slice_vs_exact_match:
479
479
480
480
Slice vs. exact match
481
-
^^^^^^^^^^^^^^^^^^^^^
481
+
~~~~~~~~~~~~~~~~~~~~~
482
+
483
+
.. versionchanged:: 0.20.0
482
484
483
485
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.
484
486
@@ -492,20 +494,20 @@ For example, let us consider ``Series`` object which index has minute resolution
492
494
'2012-01-01 00:02:00']))
493
495
series_minute.index.resolution
494
496
495
-
Timestamp string less accurate than minute gives ``Series`` object.
497
+
A Timestamp string less accurate than a minute gives a ``Series`` object.
496
498
497
499
.. ipython:: python
498
500
499
501
series_minute['2011-12-31 23']
500
502
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.
502
504
503
505
.. ipython:: python
504
506
505
507
series_minute['2011-12-31 23:59']
506
508
series_minute['2011-12-31 23:59:00']
507
509
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``.
509
511
510
512
.. ipython:: python
511
513
@@ -524,13 +526,16 @@ If the timestamp string is treated as a slice, it can be used to index ``DataFra
524
526
index=series_minute.index)
525
527
dft_minute['2011-12-31 23']
526
528
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:
528
529
529
-
To select a single row, use ``.loc``.
530
+
:: warning:
530
531
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
532
537
533
-
dft_minute.loc['2011-12-31 23:59']
538
+
dft_minute.loc['2011-12-31 23:59']
534
539
535
540
Note also that ``DatetimeIndex`` resolution cannot be less precise than day.
536
541
@@ -544,12 +549,12 @@ Note also that ``DatetimeIndex`` resolution cannot be less precise than day.
544
549
series_monthly['2011-12'] # returns Series
545
550
546
551
547
-
Datetime Indexing
548
-
~~~~~~~~~~~~~~~~~
552
+
Exact Indexing
553
+
~~~~~~~~~~~~~~
549
554
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*.
551
556
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``).
553
558
554
559
.. ipython:: python
555
560
@@ -578,10 +583,10 @@ regularity will result in a ``DatetimeIndex`` (but frequency is lost):
578
583
579
584
ts[[0, 2, 6]].index
580
585
581
-
.. _timeseries.offsets:
586
+
.. _timeseries.components:
582
587
583
588
Time/Date Components
584
-
~~~~~~~~~~~~~~~~~~~~~~~~~~~
589
+
--------------------
585
590
586
591
There are several time/date properties that one can access from ``Timestamp`` or a collection of timestamps like a ``DateTimeIndex``.
587
592
@@ -617,6 +622,8 @@ There are several time/date properties that one can access from ``Timestamp`` or
617
622
618
623
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>`
0 commit comments