簡體   English   中英

如果熊貓列中只有單詞,如何在熊貓數據框中刪除一行

[英]How to drop a row in pandas dataframe if there is only word in a pandas column

如果列中有一個只有一個單詞的項目,我們如何在 Pandas 數據幀上刪除整行

例子:

'the cat likes mice',
'the dog likes the cat',
'dog'

返回

'the cat likes mice',
'the dog likes the cat'

如何使用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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM