Skip to content

Commit 1b2f580

Browse files
TST: Verify filtering operations on DataFrames with categorical Series (#35233)
1 parent 653f091 commit 1b2f580

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pandas/tests/frame/indexing/test_categorical.py

+11
Original file line numberDiff line numberDiff line change
@@ -394,3 +394,14 @@ def test_loc_indexing_preserves_index_category_dtype(self):
394394

395395
result = df.loc[["a"]].index.levels[0]
396396
tm.assert_index_equal(result, expected)
397+
398+
def test_categorical_filtering(self):
399+
# GH22609 Verify filtering operations on DataFrames with categorical Series
400+
df = pd.DataFrame(data=[[0, 0], [1, 1]], columns=["a", "b"])
401+
df["b"] = df.b.astype("category")
402+
403+
result = df.where(df.a > 0)
404+
expected = df.copy()
405+
expected.loc[0, :] = np.nan
406+
407+
tm.assert_equal(result, expected)

0 commit comments

Comments
 (0)