@@ -225,3 +225,65 @@ def test_isin_not_lossy(self):
225225 result = df .isin ([val ])
226226 expected = DataFrame ({"a" : [True ], "b" : [False ]})
227227 tm .assert_frame_equal (result , expected )
228+
229+ @pytest .mark .parametrize (
230+ "values_df,expected" ,
231+ [
232+ # Case 1: Same values, different order
233+ (
234+ DataFrame ({"A" : [2 , 1 ], "B" : [0 , 2 ]}),
235+ DataFrame ({"A" : [True , True ], "B" : [True , True ]}),
236+ ),
237+ # Case 2: Subset of values
238+ (
239+ DataFrame ({"A" : [1 ], "B" : [0 ]}),
240+ DataFrame ({"A" : [True , False ], "B" : [True , False ]}),
241+ ),
242+ # Case 3: No matching values
243+ (
244+ DataFrame ({"A" : [5 , 6 ], "B" : [7 , 8 ]}),
245+ DataFrame ({"A" : [False , False ], "B" : [False , False ]}),
246+ ),
247+ # Case 4: Missing column
248+ pytest .param (
249+ DataFrame ({"A" : [1 , 2 ]}),
250+ DataFrame ({"A" : [True , True ], "B" : [False , False ]}),
251+ id = "missing_column" ,
252+ ),
253+ ],
254+ )
255+ def test_isin_ignore_index (self , values_df , expected ):
256+ """
257+ Test DataFrame.isin() with ignore_index=True for various scenarios.
258+
259+ GH#62620
260+ """
261+ df = DataFrame ({"A" : [1 , 2 ], "B" : [0 , 2 ]})
262+ result = df .isin (values_df , ignore_index = True )
263+ tm .assert_frame_equal (result , expected )
264+
265+ def test_isin_ignore_index_with_duplicates (self ):
266+ """
267+ Test that ignore_index=True works correctly with duplicate values.
268+
269+ GH#62620
270+ """
271+ df = DataFrame ({"A" : [1 , 2 , 3 ], "B" : [0 , 0 , 0 ]})
272+ values = DataFrame ({"A" : [1 , 1 , 2 ], "B" : [0 , 0 , 0 ]})
273+ result = df .isin (values , ignore_index = True )
274+ expected = DataFrame ({"A" : [True , True , False ], "B" : [True , True , True ]})
275+ tm .assert_frame_equal (result , expected )
276+
277+ def test_isin_ignore_index_diff_indexes (self ):
278+ """
279+ Test that ignore_index=True correctly ignores index values.
280+
281+ GH#62620
282+ """
283+ df = DataFrame ({"A" : [1 , 2 ], "B" : [0 , 2 ]}, index = ["row1" , "row2" ])
284+ values = DataFrame ({"A" : [2 , 1 ], "B" : [2 , 0 ]}, index = ["x" , "y" ])
285+ result = df .isin (values , ignore_index = True )
286+ expected = DataFrame (
287+ {"A" : [True , True ], "B" : [True , True ]}, index = ["row1" , "row2" ]
288+ )
289+ tm .assert_frame_equal (result , expected )
0 commit comments