2017-10-06 118 views
1

我有以下代码:Python字符串长度的两个值

errors = the_data.loc[the_data['Column'].str.len() != 2 or 3] 

基本上,我想当列值不长2个或3个字符被标记的行。它可以正常工作,当我有这样的:

errors = the_data.loc[the_data['Column'].str.len() != 3] 

有什么建议吗?

+1

没有为字符串没有'.LEN()'方法,你要么意味着'STR .__ LEN __()'或'LEN(STR)'。 (len()!= 2)或(true),总是为真(len()!= 2或3)。 –

回答

0

也许走正道是

errors = the_data.loc[not (2 <= len(the_data['Column']) <= 3)]