浮点对象不是s的属性

2024-09-27 00:22:19 发布

您现在位置:Python中文网/ 问答频道 /正文

数据框中的一列是icno(下面),它是成员的国家识别卡号码。我正在尝试创建另一个专栏,用function和apply方法嗅出前面带有'S'的那些。但我收到了下面的错误信息。有人能指出问题吗?谢谢!在

enter image description here

def f(x):
        if x['IC No_'].str.startswith('S',na=False): return 1
        else : return 0
MbrKPI['Sing']=MbrKPI.apply(f,axis=1) 

AttributeError: ("'float' object has no attribute 'str'", 'occurred at index 0')


Tags: 数据方法returnifdeffunction成员国家

热门问题