'get the index of search item in a dataframe
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?
Solution 1:[1]
df.index[df['combine'].str.contains(S, regex=False)].tolist()
This will generate you an index numbers list of 'combine' containing string S
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Ze'ev Ben-Tsvi |