4

What I want to do I figured would look like this:

(t in df[self.target]).any()

But I am getting:

AttributeError: 'bool' object has no attribute 'any'
birdmw
  • 865
  • 10
  • 18

2 Answers2

4

You can use Pandas str methods (docs).

df[self.target].str.contains(t).any()
Alex
  • 18,484
  • 8
  • 60
  • 80
0

I'm assuming it's a pandas DataFrame. Try this

(df[self.target] == t).any()

EDIT:

any((t in k for k in df[self.target]))
Asish M.
  • 2,588
  • 1
  • 16
  • 31