擅长:python、mysql、java
<p>我想你可以用<a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.str.lower.html" rel="nofollow">^{<cd1>}</a>和<a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.str.replace.html" rel="nofollow">^{<cd2>}</a>来表示任意空格<code>s/+</code>:</p>
<pre><code>test = pd.DataFrame({'A': ["john doe", " john doe", 'John'],
'B': [' john doe', 'eddie murphy', 'batman']})
print test['A'].str.lower().str.replace('s/+',"") ==
test['B'].str.strip().str.replace('s/+',"")
0 True
1 False
2 False
dtype: bool
</code></pre>