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
+15-13
Original file line number
Diff line number
Diff line change
@@ -1888,31 +1888,39 @@ 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
+
.. _timeseries.backward-resample:
1892
+
1891
1893
Backward resample
1892
1894
~~~~~~~~~~~~~~~~~
1893
1895
1894
1896
.. versionadded:: 1.2.0
1895
1897
1896
-
``origin`` can not only make a foreward resample, namely grouping from the starting point with the given ``freq``, but is also able to implement the backward resample. This method allows users to control bins of the grouping from the given origin with a backward direction. (:issue:`37804`)
1898
+
``origin`` can not only make a foreward resample, namely grouping from the starting point with the given ``freq``, but is also able to implement the backward resample. This method allows users to control bins of the grouping from the given origin with a backward direction. (:issue:`37804`)
1897
1899
1898
1900
.. ipython:: python
1899
1901
1900
1902
start, end ="2000-10-01 23:30:00", "2000-10-02 00:26:00"
1901
-
rng = date_range(start, end, freq="7min")
1902
-
ts = Series(np.arange(len(rng)) *3, index=rng)
1903
+
rng =pd.date_range(start, end, freq="7min")
1904
+
ts =pd.Series(np.arange(len(rng)) *3, index=rng)
1903
1905
1904
-
Setting ``offset='end'`` means using the max ``Timestamp`` as the ``origin`` with ``backward=True``.
1906
+
Setting ``offset='end'`` means using the max ``Timestamp`` as the ``origin`` with ``backward=True``.
1905
1907
1906
1908
ts.index.max()
1907
1909
ts.resample("17min", origin="end").sum()
1908
1910
1909
-
Setting ``offset='end'`` means using the ceiling midnight of the max ``Timestamp`` as the ``origin`` with ``backward=True`` .
1911
+
The forward resample output stands for the grouping result from current datetimeindex to the next one with ``closed=left`` by default. In contrast, the backward resample output stands for the grouping result from former datetimeindex to the current one with ``closed=right`` by default. If you want to change this, ``closed=left`` is available.
Copy file name to clipboardExpand all lines: doc/source/whatsnew/v1.2.0.rst
+9-21
Original file line number
Diff line number
Diff line change
@@ -206,47 +206,35 @@ level-by-level basis.
206
206
207
207
.. _whatsnew_120.backward_resample:
208
208
209
-
Backward resample
209
+
Backward resample
210
210
^^^^^^^^^^^^^^^^^
211
211
212
-
:class:`Grouper` and :meth:`DataFrame.resample` now support the argument ``backward``. ``'end'`` and ``'end_day'`` are available in argument ``offset``. Backward resample allows users to control bins of the grouping from the given origin with a backward direction. (:issue:`37804`)
212
+
:class:`Grouper` and :meth:`DataFrame.resample` now support the argument ``backward``. ``'end'`` and ``'end_day'`` are available in argument ``offset``. Backward resample allows users to control bins of the grouping from the given origin with a backward direction. (:issue:`37804`)
213
213
214
214
.. ipython:: python
215
215
216
216
start, end ="2000-10-01 23:30:00", "2000-10-02 00:26:00"
217
-
rng = date_range(start, end, freq="7min")
218
-
ts = Series(np.arange(len(rng)) *3, index=rng)
217
+
rng =pd.date_range(start, end, freq="7min")
218
+
ts =pd.Series(np.arange(len(rng)) *3, index=rng)
219
219
220
-
Setting ``offset='end'`` means using the max ``Timestamp`` as the ``origin`` with ``backward=True``.
220
+
Setting ``offset='end'`` means using the max ``Timestamp`` as the ``origin`` with ``backward=True``.
221
221
222
222
ts.index.max()
223
223
ts.resample("17min", origin="end").sum()
224
224
225
-
Setting ``offset='end'`` means using the ceiling midnight of the max ``Timestamp`` as the ``origin`` with ``backward=True``.
225
+
Setting ``offset='end_day'`` means using the ceiling midnight of the max ``Timestamp`` as the ``origin`` with ``backward=True``.
226
226
227
227
.. ipython:: python
228
228
229
-
ts.resample("17min", origin="end").sum()
229
+
ts.resample("17min", origin="end_day").sum()
230
230
231
-
If you want to make the backward resample from a Timestamp-like ``origin``, ``backward=True`` should be set.
231
+
If you want to make the backward resample from a Timestamp-like ``origin``, ``backward=True`` should be set.
0 commit comments