我试图从一个 Dataframe 中删除包含连续数字的行,如1234或6789…
# Define regular expression pattern for sequential digits
pattern = r'\{3,}'
mask = df1['prix'].str.contains(pattern)
df_filtered = df1[mask]
print(df_filtered)
我试过这段代码,但它返回相同的数据,当我尝试这一个之前
pattern = r'\d{3,}'
df1['prix'] = df1['prix'].astype(str)
mask = df1['prix'].str.contains(pattern)
if mask.any():
print("There are rows with sequential digits.")
else:
print("There are no rows with sequential digits.")
它返回数据具有连续的数字
1条答案
按热度按时间h7appiyu1#
您可以使用以下正则表达式:
输出: