Skip to content

Commit 8d62fb0

Browse files
josemayerwangwillian0mroeschke
committed
TST: add test case of ngroup with NaN value (pandas-dev#54966)
* add test case of ngroup with nan value Co-authored-by: José Lucas Silva Mayer <[email protected]> Co-authored-by: Willian Wang <[email protected]> * fix linter issues Co-authored-by: José Lucas Silva Mayer <[email protected]> Co-authored-by: Willian Wang <[email protected]> * use Categorical object instead of pd.Categorical Co-authored-by: José Lucas Silva Mayer <[email protected]> Co-authored-by: Willian Wang <[email protected]> * use native assert function Co-authored-by: Matthew Roeschke <[email protected]> * test full result of ngroup method Signed-off-by: José Lucas Silva Mayer <[email protected]> --------- Signed-off-by: José Lucas Silva Mayer <[email protected]> Co-authored-by: Willian Wang <[email protected]> Co-authored-by: Matthew Roeschke <[email protected]>
1 parent d7a203d commit 8d62fb0

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pandas/tests/groupby/test_groupby.py

+8
Original file line numberDiff line numberDiff line change
@@ -3189,6 +3189,14 @@ def test_depr_get_group_len_1_list_likes(test_series, kwarg, value, name, warn):
31893189
tm.assert_equal(result, expected)
31903190

31913191

3192+
def test_groupby_ngroup_with_nan():
3193+
# GH#50100
3194+
df = DataFrame({"a": Categorical([np.nan]), "b": [1]})
3195+
result = df.groupby(["a", "b"], dropna=False, observed=False).ngroup()
3196+
expected = Series([0])
3197+
tm.assert_series_equal(result, expected)
3198+
3199+
31923200
def test_get_group_axis_1():
31933201
# GH#54858
31943202
df = DataFrame(

0 commit comments

Comments
 (0)