Skip to content

Commit 0485115

Browse files
HubertKlWillAyd
authored andcommitted
BUG: Issue pandas-dev#29128 Series.var not returning the correct result (pandas-dev#29353)
1 parent e423bac commit 0485115

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

doc/source/whatsnew/v1.0.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ Numeric
342342
- :class:`DataFrame` flex inequality comparisons methods (:meth:`DataFrame.lt`, :meth:`DataFrame.le`, :meth:`DataFrame.gt`, :meth: `DataFrame.ge`) with object-dtype and ``complex`` entries failing to raise ``TypeError`` like their :class:`Series` counterparts (:issue:`28079`)
343343
- Bug in :class:`DataFrame` logical operations (`&`, `|`, `^`) not matching :class:`Series` behavior by filling NA values (:issue:`28741`)
344344
- Bug in :meth:`DataFrame.interpolate` where specifying axis by name references variable before it is assigned (:issue:`29142`)
345+
- Bug in :meth:`Series.var` not computing the right value with a nullable integer dtype series not passing through ddof argument (:issue:`29128`)
345346
- Improved error message when using `frac` > 1 and `replace` = False (:issue:`27451`)
346347
- Bug in numeric indexes resulted in it being possible to instantiate an :class:`Int64Index`, :class:`UInt64Index`, or :class:`Float64Index` with an invalid dtype (e.g. datetime-like) (:issue:`29539`)
347348
- Bug in :class:`UInt64Index` precision loss while constructing from a list with values in the ``np.uint64`` range (:issue:`29526`)

pandas/core/arrays/integer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ def _reduce(self, name, skipna=True, **kwargs):
647647
data[mask] = self._na_value
648648

649649
op = getattr(nanops, "nan" + name)
650-
result = op(data, axis=0, skipna=skipna, mask=mask)
650+
result = op(data, axis=0, skipna=skipna, mask=mask, **kwargs)
651651

652652
# if we have a boolean op, don't coerce
653653
if name in ["any", "all"]:

pandas/tests/arrays/test_integer.py

+20
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,26 @@ def test_arrow_array(data):
829829
assert arr.equals(expected)
830830

831831

832+
@pytest.mark.parametrize(
833+
"pandasmethname, kwargs",
834+
[
835+
("var", {"ddof": 0}),
836+
("var", {"ddof": 1}),
837+
("kurtosis", {}),
838+
("skew", {}),
839+
("sem", {}),
840+
],
841+
)
842+
def test_stat_method(pandasmethname, kwargs):
843+
s = pd.Series(data=[1, 2, 3, 4, 5, 6, np.nan, np.nan], dtype="Int64")
844+
pandasmeth = getattr(s, pandasmethname)
845+
result = pandasmeth(**kwargs)
846+
s2 = pd.Series(data=[1, 2, 3, 4, 5, 6], dtype="Int64")
847+
pandasmeth = getattr(s2, pandasmethname)
848+
expected = pandasmeth(**kwargs)
849+
assert expected == result
850+
851+
832852
# TODO(jreback) - these need testing / are broken
833853

834854
# shift

0 commit comments

Comments
 (0)