Pandas 判断字符串类型

来源:互联网 发布:淘宝ck代购是正品吗 编辑:程序博客网 时间:2024/05/16 14:26
In [1]: import pandas as pd   ...: df=pd.Series(["1","a",1])   ...: dfOut[1]: 0    11    a2    1dtype: objectIn [2]: df.str.isnumeric()Out[2]: 0     True1    False2      NaNdtype: objectIn [3]: df.str.isalnum()Out[3]: 0    True1    True2     NaNdtype: objectIn [4]: df.str.isalpha()Out[4]: 0    False1     True2      NaNdtype: object

NaN的意思是这不是一个字符串,所以可以用这个语句来分别字符串和非字符串