Skip to content

Commit 4fec5df

Browse files
louisjbrockmendel
louis
authored andcommitted
TST: Test for fix of type issue in empty groupby from DataFrame with categorical.
1 parent 8e4424f commit 4fec5df

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pandas/tests/groupby/test_groupby.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1825,6 +1825,18 @@ def test_groupby_empty_list_raises():
18251825
df.groupby([[]])
18261826

18271827

1828+
def test_groupby_with_empty_category():
1829+
# GH-9614
1830+
df = pd.DataFrame({"id": [None] * 3, "spam": [None] * 3})
1831+
df["spam"] = df["spam"].astype("category")
1832+
df["spam"] == "spam" # works as expected
1833+
result = df.groupby("id").first()["spam"] == "spam"
1834+
expected = Series(
1835+
[], name="spam", dtype=bool, index=pd.Series([], dtype="object", name="id")
1836+
)
1837+
tm.assert_series_equal(result, expected)
1838+
1839+
18281840
def test_groupby_multiindex_series_keys_len_equal_group_axis():
18291841
# GH 25704
18301842
index_array = [["x", "x"], ["a", "b"], ["k", "k"]]

0 commit comments

Comments
 (0)