2017-10-06 117 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)]