Python 3.x 如何在熊猫身上找到多重空间
当其中一列包含目标值时,我编写以下代码Python 3.x 如何在熊猫身上找到多重空间,python-3.x,pandas,Python 3.x,Pandas,当其中一列包含目标值时,我编写以下代码 df['address'].str.contains('\t') 在我的问题中,我想找到大于2个空间的多个空间。 我想我应该使用正则表达式 如何编写代码?请给我一个建议 这是一个好例子吗 df = pd.DataFrame({'col': ['a', 'b ', 'c', ' d', ' e ']}) col 0 a 1 b 2 c 3 d 4 e 单向使用 s=
df['address'].str.contains('\t')
在我的问题中,我想找到大于2个空间的多个空间。
我想我应该使用正则表达式
如何编写代码?请给我一个建议 这是一个好例子吗
df = pd.DataFrame({'col': ['a', 'b ', 'c', ' d', ' e ']})
col
0 a
1 b
2 c
3 d
4 e
单向使用
s=pd.Series(['one ','more than two','only two'])
s.str.contains(' ')
0 False
1 True
2 True
dtype: bool
如果我们想找到单个空间频率,我们可以做count
s.str.count(' ')
0 1
1 4
2 2
dtype: int64
我发布的任何连续(可能重复)单词的基于正则表达式的方法如下:多空格是什么意思?
s.str.count(' ')
0 1
1 4
2 2
dtype: int64