I have a pandas data frame as follows:
id | left | top | width | height | Text |
---|---|---|---|---|---|
1 | 12 | 34 | 12 | 34 | commercial |
2 | 99 | 42 | 99 | 42 | general |
3 | 1 | 47 | 9 | 4 | liability |
4 | 10 | 69 | 32 | 67 | commercial |
5 | 99 | 72 | 79 | 88 | available |
I want to extract specific rows based on the column value Text
. So I want to search for certain keyphrases like liability commercial
using re.search
in the column Text
and if I get a match then extract the rows i.e. 3rd and 4th row. So if the input is liability commercial
then the output should be the following rows extracted:
id | left | top | width | height | Text |
---|---|---|---|---|---|
3 | 1 | 47 | 9 | 4 | liability |
4 | 10 | 69 | 32 | 67 | commercial |
Keep in mind that the column Text
may contain duplicate values. So in the above case, there are 2 rows with the word commerial
present.
Thanks in advance!