Skip to content

Commit b74c98a

Browse files
author
Sebastian Goldmann
committed
adjusted window tests
1 parent ade3f0c commit b74c98a

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

pandas/_libs/window/aggregations.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,9 +498,9 @@ cdef float64_t calc_skew(int64_t minp, int64_t nobs,
498498
if nobs < 3:
499499
result = NaN
500500
# GH 42064 46431
501-
# uniform case, force result to be 0
501+
# uniform case, force result to be NaN
502502
elif num_consecutive_same_value >= nobs:
503-
result = 0.0
503+
result = NaN
504504
# #18044: with uniform distribution, floating issue will
505505
# cause B != 0. and cause the result is a very
506506
# large number.

pandas/tests/window/test_rolling_skew_kurt.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def test_center_reindex_frame(frame, roll_func):
170170

171171

172172
def test_rolling_skew_edge_cases(step):
173-
expected = Series([np.nan] * 4 + [0.0])[::step]
173+
expected = Series([np.nan] * 5)[::step]
174174
# yields all NaN (0 variance)
175175
d = Series([1] * 5)
176176
x = d.rolling(window=5, step=step).skew()
@@ -191,7 +191,7 @@ def test_rolling_skew_edge_cases(step):
191191

192192

193193
def test_rolling_kurt_edge_cases(step):
194-
expected = Series([np.nan] * 4 + [-3.0])[::step]
194+
expected = Series([np.nan] * 5)[::step]
195195

196196
# yields all NaN (0 variance)
197197
d = Series([1] * 5)
@@ -212,16 +212,14 @@ def test_rolling_kurt_edge_cases(step):
212212

213213

214214
def test_rolling_skew_eq_value_fperr(step):
215-
# #18804 all rolling skew for all equal values should return Nan
215+
# #18804 all rolling skew for all equal values should return NaN
216216
# #46717 update: all equal values should return 0 instead of NaN
217217
a = Series([1.1] * 15).rolling(window=10, step=step).skew()
218-
assert (a[a.index >= 9] == 0).all()
219-
assert a[a.index < 9].isna().all()
218+
assert a.isna().all()
220219

221220

222221
def test_rolling_kurt_eq_value_fperr(step):
223222
# #18804 all rolling kurt for all equal values should return Nan
224223
# #46717 update: all equal values should return -3 instead of NaN
225224
a = Series([1.1] * 15).rolling(window=10, step=step).kurt()
226-
assert (a[a.index >= 9] == -3).all()
227-
assert a[a.index < 9].isna().all()
225+
assert a.isna().all()

0 commit comments

Comments
 (0)