為什么即使在調(diào)用 str.strip 后,數(shù)字值仍被視為非數(shù)字?這是我的情況:df['ID'] = df['ID'].str.strip()id = df['ID']indices = [ i for (i, v) in enumerate(id.str.isnumeric()) if v == False ]non_numeric = id.filter(indices)id.head(-5)And this is the output of id.head(-5):141 C536379154 C536383235 C536391236 C536391237 C536391 ... 470612 576618470614 576618470616 576618470618 576618470673 576618Name: ID, Length: 7892, dtype: object為什么所有這些不以字母開頭的數(shù)字仍然存在于 non_numeric 數(shù)組中?起初我以為這是由于前導空格造成的,但后來我添加了 strip() 并且沒有任何改變。編輯:我需要分析系列中的非數(shù)值,所以我試圖提取它們。
pandas 數(shù)值顯示在非數(shù)字系列中
幕布斯6054654
2023-12-12 10:04:49