0

I am trying to get the index of a data frame where the rows contain exact same strings of my interest. This is my attempt:

import re
     findheaderindex = b[re.match(b.apply(lambda row: row.astype(str)),'start|finish|client')].index

I am trying to find the indices where the strings match the ones I have listed in the re.match function.

I was using the following code, which is working

findheaderindex = b[b.apply(lambda row: row.astype(str).str.contains('start|finish|client').any(), axis=1)].index

But the problem is that this gives me any rows that contain the strings, such as Finishing, Starting, or other similar words, and I don't want that to happen in my operation. So, how do I do a string literal match in python to find the indices?

user86907
  • 817
  • 9
  • 21

0 Answers0