Reputation: 1568
Assume I got an array, created by a pandas dataframe with array = df.index.values
and looks like following:
array
array(['A', 'B', 'C', 'D',
'E', 'F', 'G', 'H'], dtype=object)
and I got a python list looks like following:
list = ['AB', 'AC', 'AD', 'AE', 'AF', 'AG', 'A']
Looking for a function, which does following:
If any element of array is also in list, give me True. If not give me False.
PS: I am not looking for finding the element. Just want to know if such element exist.
Upvotes: 0
Views: 284
Reputation: 863226
Pandas solution with Index.isin
and Index.any
:
df.index.isin(List).any()
Upvotes: 2