-1

I have a pandas Serie containing some strings

s = pd.Series(['a', 'b', 'c', 'd', 'a'], index=[1, 2, 3, 4, 5])

How can I get a serie of True/False based on equality of a string? For example I want to check the positions of all 'a' and from the example above I want to get as a result

True, False, False, False, True
prre72
  • 697
  • 2
  • 12
  • 23

2 Answers2

-1

I have found a solution in the mean time!

res = s.str.contains("a")

prre72
  • 697
  • 2
  • 12
  • 23
-1
np.where(s=='a', 'true', 'false')
nimrodz
  • 1,504
  • 1
  • 13
  • 18