Home > Software design >  get the index of search item in a dataframe
get the index of search item in a dataframe

Time:05-14

I have a dataframe which contain a column

            combine
0   (43,FR,html5 full skinz html5)
1   (43,FR,mobile m-skinz2)
2   (43,FR,mobile m-skinz2 plus)
3   (43,FR,mobile m-skinz2 swipetosite)

I am looking for a way to find a string S in the combine column and get its index.

Is there any python function to use?

CodePudding user response:

df.index[df['combine'].str.contains(S, regex=False)].tolist()

This will generate you an index numbers list of 'combine' containing string S

  • Related