[英]How to drop a row in pandas dataframe if there is only word in a pandas column
How do we drop an entire row on pandas dataframe if there is an item in a column that only has one word如果列中有一个只有一个单词的项目,我们如何在 Pandas 数据帧上删除整行
Example:例子:
'the cat likes mice',
'the dog likes the cat',
'dog'
Return返回
'the cat likes mice',
'the dog likes the cat'
How about using the pd.Series.str.contains
method to look for spaces:如何使用pd.Series.str.contains
方法查找空格:
df = pd.DataFrame({'items': ['the cat likes mice',
'the dog likes the cat',
'dog']})
df = df[df['items'].str.contains(' ')]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.