【报错】"cannot convert the series to class 'float'

def is_number(s):
    try:
        float(s)
        return True
    except ValueError:
        pass 
    try:
        import unicodedata
        unicodedata.numeric(s)
        return True
    except (TypeError, ValueError):
        pass
    return False

def weihao(a):
    if is_number(a.str.slice(6,7))==True:
        return a.str.slice(6,7)
    elif is_number(a.str.slice(5,6))==True:
        return a.str.slice(5,6)
    elif is_number(a.str.slice(4,5))==True:
        return a.str.slice(4,5)
    elif is_number(a.str.slice(3,4))==True:
        return a.str.slice(3,4)
汇总0901['尾号'] = 汇总0901.apply(lambda x:
    weihao(汇总0901.车牌号),axis = 1)

TypeError: ("cannot convert the series to ", 'occurred at index 0')

cannot convert the series to

你可能感兴趣的:(python初探)