pandas.DataFrame.isin — pandas 0.16.2 documentation (original) (raw)

Return boolean DataFrame showing whether each element in the DataFrame is contained in values.

df = DataFrame({'A': [1, 2, 3], 'B': ['a', 'b', 'f']}) df.isin([1, 3, 12, 'a']) A B 0 True True 1 False False 2 True False

df = DataFrame({'A': [1, 2, 3], 'B': [1, 4, 7]}) df.isin({'A': [1, 3], 'B': [4, 7, 12]}) A B 0 True False # Note that B didn't match the 1 here. 1 False True 2 True True

df = DataFrame({'A': [1, 2, 3], 'B': ['a', 'b', 'f']}) other = DataFrame({'A': [1, 3, 3, 2], 'B': ['e', 'f', 'f', 'e']}) df.isin(other) A B 0 True False 1 False False # Column A in other has a 3, but not at index 1. 2 True True