groupby does something else completely. He creates groups for aggregation. It basically comes from something like:
['a', 'b', 'a', 'c', 'b', 'b']
to something like:
[['a', 'a'], ['b', 'b', 'b'], ['c']]
You want df.apply .
pandas versions of pandas have a query method that makes this a bit more efficient and easy.
However, what needs to be done to make a boolean array with
mask = df.Type.apply(lambda x: 'Fruit' in x)
Then select the appropriate parts of the data frame with df[mask] . Or, as a single line:
df[df.Type.apply(lambda x: 'Fruit' in x)]
As a complete example:
import pandas as pd data = [['Orange', 'Edible, Fruit'], ['Banana', 'Edible, Fruit'], ['Tomato', 'Edible, Vegtable'], ['Laptop', 'Non Edible, Electronic']] df = pd.DataFrame(data, columns=['Item', 'Type']) print df[df.Type.apply(lambda x: 'Fruit' in x)]