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/user_guide/timeseries.rst
+28
Original file line number
Diff line number
Diff line change
@@ -1888,6 +1888,34 @@ Those two examples are equivalent for this time series:
1888
1888
1889
1889
Note the use of ``'start'`` for ``origin`` on the last example. In that case, ``origin`` will be set to the first value of the timeseries.
1890
1890
1891
+
Backward resample
1892
+
~~~~~~~~~~~~~~~~~
1893
+
1894
+
.. versionadded:: 1.3.0
1895
+
1896
+
Instead of adjusting the beginning of bins, sometimes we need to fix the end of the bins to make a backward resample with a given ``freq``. The backward resample sets ``closed`` to ``'right'`` by default since the last value should be considered as the edge point for the last bin.
1897
+
1898
+
We can set ``origin`` to ``'end'``. The value for a specific ``Timestamp`` index stands for the resample result from the current ``Timestamp`` minus ``freq`` to the current ``Timestamp`` with a right close.
1899
+
1900
+
.. ipython:: python
1901
+
1902
+
ts.resample('17min', origin='end').sum()
1903
+
1904
+
Besides, in contrast with the ``'start_day'`` option, ``end_day`` is supported. This will set the origin as the ceiling midnight of the largest ``Timestamp``.
1905
+
1906
+
.. ipython:: python
1907
+
1908
+
ts.resample('17min', origin='end_day').sum()
1909
+
1910
+
The above result uses ``2000-10-02 00:29:00`` as the last bin's right edge since the following computation.
0 commit comments