![](/img/trans.png)
[英]How to remove a word if it has more than 2 occurrence of a given character in python?
[英]Remove rows that contain more than one occurrence of a character (in any column)
您可以使用:
>>> df[~df.eq('?').sum(axis=1).gt(1)]
x y z
0 1 2 ?
1 3 2 1
3 2 3 1
如果您正在尋找包括數字在內的任何重復項,您可以嘗試:
>>> df.loc[~df.T.apply(pd.Series.duplicated, keep=False).T.any(axis=1)]
x y z
0 1 2 ?
1 3 2 1
3 2 3 1
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.