Skip to content

Commit b3b43bc

Browse files
committed
update docstring running result; reformat code; update what's new
1 parent b55d357 commit b3b43bc

File tree

3 files changed

+20
-25
lines changed

3 files changed

+20
-25
lines changed

doc/source/whatsnew/v1.5.0.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ Other enhancements
4545
- Improved error message in :class:`~pandas.core.window.Rolling` when ``window`` is a frequency and ``NaT`` is in the rolling axis (:issue:`46087`)
4646
- :class:`Series` and :class:`DataFrame` with ``IntegerDtype`` now supports bitwise operations (:issue:`34463`)
4747
- Add ``milliseconds`` field support for :class:`~pandas.DateOffset` (:issue:`43371`)
48+
- :meth:`DataFrame.rolling.var`, :meth:`DataFrame.rolling.std`, :meth:`Series.rolling.var`, :meth:`Series.rolling.std` now generate correct result 0 for window containing same values (:issue:`42064`)
4849
-
4950

5051
.. ---------------------------------------------------------------------------
@@ -251,10 +252,10 @@ Deprecations
251252

252253
.. _whatsnew_150.deprecations.int_slicing_series:
253254

254-
In a future version, integer slicing on a :class:`Series` with a :class:`Int64Index` or :class:`RangeIndex` will be treated as *label-based*, not positional. This will make the behavior consistent with other :meth:`Series.__getitem__` and :meth:`Series.__setitem__` behaviors (:issue:`45162`).
255+
In a future version, integer slicing on a :class:`Series` with a :class:`Int64Index` or :class:`RangeIndex` will be treated as *label-based*, not positional. This will make the behavior consisent with other :meth:`Series.__getitem__` and :meth:`Series.__setitem__` behaviors (:issue:`45162`).
255256

256257
For example:
257-
258+
t
258259
.. ipython:: python
259260
260261
ser = pd.Series([1, 2, 3, 4, 5], index=[2, 3, 5, 7, 11])

pandas/core/_numba/kernels/var_.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def add_var(
2222
ssqdm_x: float,
2323
compensation: float,
2424
num_consecutive_same_value: int,
25-
prev_value: float
25+
prev_value: float,
2626
) -> tuple[int, float, float, float, int, float]:
2727
if not np.isnan(val):
2828

pandas/core/window/rolling.py

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2150,24 +2150,21 @@ def median(
21502150
The default ``ddof`` of 1 used in :meth:`Series.std` is different
21512151
than the default ``ddof`` of 0 in :func:`numpy.std`.
21522152
2153-
A minimum of one period is required for the rolling calculation.
2154-
2155-
The implementation is susceptible to floating point imprecision as
2156-
shown in the example below.\n
2153+
A minimum of one period is required for the rolling calculation.\n
21572154
"""
21582155
).replace("\n", "", 1),
21592156
create_section_header("Examples"),
21602157
dedent(
21612158
"""
21622159
>>> s = pd.Series([5, 5, 6, 7, 5, 5, 5])
21632160
>>> s.rolling(3).std()
2164-
0 NaN
2165-
1 NaN
2166-
2 5.773503e-01
2167-
3 1.000000e+00
2168-
4 1.000000e+00
2169-
5 1.154701e+00
2170-
6 2.580957e-08
2161+
0 NaN
2162+
1 NaN
2163+
2 0.577350
2164+
3 1.000000
2165+
4 1.000000
2166+
5 1.154701
2167+
6 0.000000
21712168
dtype: float64
21722169
"""
21732170
).replace("\n", "", 1),
@@ -2212,24 +2209,21 @@ def std(
22122209
The default ``ddof`` of 1 used in :meth:`Series.var` is different
22132210
than the default ``ddof`` of 0 in :func:`numpy.var`.
22142211
2215-
A minimum of one period is required for the rolling calculation.
2216-
2217-
The implementation is susceptible to floating point imprecision as
2218-
shown in the example below.\n
2212+
A minimum of one period is required for the rolling calculation.\n
22192213
"""
22202214
).replace("\n", "", 1),
22212215
create_section_header("Examples"),
22222216
dedent(
22232217
"""
22242218
>>> s = pd.Series([5, 5, 6, 7, 5, 5, 5])
22252219
>>> s.rolling(3).var()
2226-
0 NaN
2227-
1 NaN
2228-
2 3.333333e-01
2229-
3 1.000000e+00
2230-
4 1.000000e+00
2231-
5 1.333333e+00
2232-
6 6.661338e-16
2220+
0 NaN
2221+
1 NaN
2222+
2 0.333333
2223+
3 1.000000
2224+
4 1.000000
2225+
5 1.333333
2226+
6 0.000000
22332227
dtype: float64
22342228
"""
22352229
).replace("\n", "", 1),

0 commit comments

Comments
 (0)