Reputation: 168
How do we drop an entire row on pandas dataframe if there is an item in a column that only has one word
Example:
'the cat likes mice',
'the dog likes the cat',
'dog'
Return
'the cat likes mice',
'the dog likes the cat'
Upvotes: 1
Views: 38
Reputation: 2714
How about using the pd.Series.str.contains
method to look for spaces:
df = pd.DataFrame({'items': ['the cat likes mice',
'the dog likes the cat',
'dog']})
df = df[df['items'].str.contains(' ')]
Upvotes: 1