Skip to content

Commit dcb395d

Browse files
committed
Add issue number to whatsnew, make test more readable
1 parent 00386b0 commit dcb395d

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

doc/source/whatsnew/v0.25.1.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ Groupby/resample/rolling
121121
- Bug in windowing over read-only arrays (:issue:`27766`)
122122
- Fixed segfault in `pandas.core.groupby.DataFrameGroupBy.quantile` when an invalid quantile was passed (:issue:`27470`)
123123
- Bug in :meth:`pandas.core.groupby.SeriesGroupBy.nunique` where ``NaT`` values were interfering
124-
with the count of unique values
124+
with the count of unique values (:issue:`27951`)
125125
-
126126

127127
Reshaping

pandas/core/groupby/generic.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1143,8 +1143,9 @@ def nunique(self, dropna=True):
11431143

11441144
val = self.obj._internal_get_values()
11451145

1146+
# GH 27951
11461147
if dropna:
1147-
mask = np.where(val == val)[0]
1148+
mask = notna(val)
11481149
ids = ids[mask]
11491150
val = val[mask]
11501151

pandas/tests/groupby/test_function.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,9 @@ def test_nunique_with_timegrouper():
10611061
],
10621062
)
10631063
def test_nunique_with_NaT(data, expected):
1064-
assert data.groupby(["key"])["data"].nunique()[0] == expected
1064+
# GH 27951
1065+
result = data.groupby(["key"])["data"].nunique()[0]
1066+
assert result == expected
10651067

10661068

10671069
def test_nunique_preserves_column_level_names():

0 commit comments

Comments
 (0)