Skip to content

Commit 458cf51

Browse files
authored
restore ddof support in std (#2447)
* restore ddof support in std * whats new
1 parent 638b251 commit 458cf51

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

doc/whats-new.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ Enhancements
4949
Bug fixes
5050
~~~~~~~~~
5151

52+
- ``xarray.DataArray.std()`` now correctly accepts ``ddof`` keyword argument.
53+
(:issue:`2240`)
54+
By `Keisuke Fujii <https://github.com/fujiisoup>`_.
5255

5356
.. _whats-new.0.10.9:
5457

xarray/core/nanops.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,9 @@ def nanvar(a, axis=None, dtype=None, out=None, ddof=0):
184184
a, axis=axis, dtype=dtype, ddof=ddof)
185185

186186

187-
def nanstd(a, axis=None, dtype=None, out=None):
187+
def nanstd(a, axis=None, dtype=None, out=None, ddof=0):
188188
return _dask_or_eager_func('nanstd', eager_module=nputils)(
189-
a, axis=axis, dtype=dtype)
189+
a, axis=axis, dtype=dtype, ddof=ddof)
190190

191191

192192
def nanprod(a, axis=None, dtype=None, out=None, min_count=None):

xarray/tests/test_duck_array_ops.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ def test_reduce(dim_num, dtype, dask, func, skipna, aggdim):
309309
assert_allclose(actual, expected, rtol=rtol)
310310

311311
# make sure the compatiblility with pandas' results.
312-
if func == 'var':
312+
if func in ['var', 'std']:
313313
expected = series_reduce(da, func, skipna=skipna, dim=aggdim,
314314
ddof=0)
315315
assert_allclose(actual, expected, rtol=rtol)

0 commit comments

Comments
 (0)