Skip to content

Commit a0262ab

Browse files
committed
Revert "fix doc"
This reverts commit b492293.
1 parent 76a015a commit a0262ab

File tree

2 files changed

+34
-24
lines changed

2 files changed

+34
-24
lines changed

doc/source/user_guide/timeseries.rst

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1888,39 +1888,31 @@ Those two examples are equivalent for this time series:
18881888
18891889
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.
18901890

1891-
.. _timeseries.backward-resample:
1892-
18931891
Backward resample
18941892
~~~~~~~~~~~~~~~~~
18951893

18961894
.. versionadded:: 1.2.0
18971895

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`)
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`)
18991897

19001898
.. ipython:: python
19011899
19021900
start, end = "2000-10-01 23:30:00", "2000-10-02 00:26:00"
1903-
rng = pd.date_range(start, end, freq="7min")
1904-
ts = pd.Series(np.arange(len(rng)) * 3, index=rng)
1901+
rng = date_range(start, end, freq="7min")
1902+
ts = Series(np.arange(len(rng)) * 3, index=rng)
19051903
1906-
Setting ``offset='end'`` means using the max ``Timestamp`` as the ``origin`` with ``backward=True``.
1904+
Setting ``offset='end'`` means using the max ``Timestamp`` as the ``origin`` with ``backward=True`` .
19071905

19081906
ts.index.max()
19091907
ts.resample("17min", origin="end").sum()
19101908

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.
1912-
1913-
.. ipython:: python
1914-
1915-
ts.resample("17min", closed="left", origin="end").sum()
1916-
1917-
Setting ``offset='end_day'`` means using the ceiling midnight of the max ``Timestamp`` as the ``origin`` with ``backward=True``.
1909+
Setting ``offset='end'`` means using the ceiling midnight of the max ``Timestamp`` as the ``origin`` with ``backward=True`` .
19181910

19191911
.. ipython:: python
19201912
1921-
ts.resample("17min", origin="end_day").sum()
1913+
ts.resample("17min", origin="end").sum()
19221914
1923-
If you want to make the backward resample from a Timestamp-like ``origin``, ``backward=True`` should be set.
1915+
If you want to make the backward resample from a Timestamp-like ``origin`` , ``backward=True`` should be set.
19241916

19251917
.. ipython:: python
19261918
@@ -1934,6 +1926,12 @@ You can implement ``offset='end_day'`` in the following method equivalently.
19341926
end_day_origin
19351927
ts.resample("17min", origin=end_day_origin, backward=True).sum()
19361928
1929+
By defualt, backward resample uses ``closed=right`` while ``closed=left`` is also available.
1930+
1931+
.. ipython:: python
1932+
1933+
ts.resample("17min", closed="left", origin="end").sum()
1934+
19371935
.. _timeseries.periods:
19381936

19391937
Time span representation

doc/source/whatsnew/v1.2.0.rst

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -206,35 +206,47 @@ level-by-level basis.
206206

207207
.. _whatsnew_120.backward_resample:
208208

209-
Backward resample
209+
Backward resample
210210
^^^^^^^^^^^^^^^^^
211211

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`)
213213

214214
.. ipython:: python
215215
216216
start, end = "2000-10-01 23:30:00", "2000-10-02 00:26:00"
217-
rng = pd.date_range(start, end, freq="7min")
218-
ts = pd.Series(np.arange(len(rng)) * 3, index=rng)
217+
rng = date_range(start, end, freq="7min")
218+
ts = Series(np.arange(len(rng)) * 3, index=rng)
219219
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`` .
221221

222222
ts.index.max()
223223
ts.resample("17min", origin="end").sum()
224224

225-
Setting ``offset='end_day'`` means using the ceiling midnight of the max ``Timestamp`` as the ``origin`` with ``backward=True``.
225+
Setting ``offset='end'`` means using the ceiling midnight of the max ``Timestamp`` as the ``origin`` with ``backward=True`` .
226226

227227
.. ipython:: python
228228
229-
ts.resample("17min", origin="end_day").sum()
229+
ts.resample("17min", origin="end").sum()
230230
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.
232232

233233
.. ipython:: python
234234
235235
ts.resample("17min", origin="2000-10-02 00:40:00", backward=True).sum()
236236
237-
For details, see: :ref:`timeseries.backward-resample`.
237+
You can implement ``offset='end_day'`` in the following method equivalently.
238+
239+
.. ipython:: python
240+
241+
end_day_origin = ts.index.max().ceil("D")
242+
end_day_origin
243+
ts.resample("17min", origin=end_day_origin, backward=True).sum()
244+
245+
By defualt, backward resample uses ``closed=right`` while ``closed=left`` is also available.
246+
247+
.. ipython:: python
248+
249+
ts.resample("17min", closed="left", origin="end").sum()
238250
239251
.. _whatsnew_120.groupby_ewm:
240252

0 commit comments

Comments
 (0)