| 13 | |
| 14 | class TestSeriesIsIn: |
| 15 | def test_isin(self): |
| 16 | s = Series(["A", "B", "C", "a", "B", "B", "A", "C"]) |
| 17 | |
| 18 | result = s.isin(["A", "C"]) |
| 19 | expected = Series([True, False, True, False, False, False, True, True]) |
| 20 | tm.assert_series_equal(result, expected) |
| 21 | |
| 22 | # GH#16012 |
| 23 | # This specific issue has to have a series over 1e6 in len, but the |
| 24 | # comparison array (in_list) must be large enough so that numpy doesn't |
| 25 | # do a manual masking trick that will avoid this issue altogether |
| 26 | s = Series(list("abcdefghijk" * 10**5)) |
| 27 | # If numpy doesn't do the manual comparison/mask, these |
| 28 | # unorderable mixed types are what cause the exception in numpy |
| 29 | in_list = [-1, "a", "b", "G", "Y", "Z", "E", "K", "E", "S", "I", "R", "R"] * 6 |
| 30 | |
| 31 | assert s.isin(in_list).sum() == 200000 |
| 32 | |
| 33 | def test_isin_with_string_scalar(self): |
| 34 | # GH#4763 |