Skip to content

Commit 9f8512b

Browse files
committed
TST: add testcase for difference using periodindex with index
1 parent c301882 commit 9f8512b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

pandas/tests/indexes/period/test_setops.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,3 +361,16 @@ def test_union_duplicates(self):
361361
freq="D",
362362
)
363363
tm.assert_index_equal(result, expected)
364+
365+
def test_difference_periodindex_with_index(self):
366+
# GH#58971
367+
index1 = period_range("2022-01", periods=5, freq="M")
368+
index2 = pd.Index(["2022-02", "2022-03"])
369+
370+
result1 = index1.difference(index2)
371+
expected1 = PeriodIndex(["2022-01", "2022-04", "2022-05"], freq="M")
372+
tm.assert_index_equal(result1, expected1)
373+
374+
result2 = index2.difference(index1)
375+
expected2 = pd.Index([])
376+
tm.assert_index_equal(result2, expected2)

0 commit comments

Comments
 (0)