pandas apply() 函数用法

https://blog.csdn.net/stone0823/article/details/100008619

df = pd.read_csv("1.csv")
df['B'] = df['A'].apply(lambda x : 5 if x != '汉' else 0)
df['D'] = df['C'] + df['B']

#直接在apply后面加方法

def getrange(x):
        # print(x[6:8])
        try:
            result = x[6:8]
        except:
            result = 'null'
        return result

data['split_point_base64']=data['split_point_base64'].apply(getrange)

 
上一篇:Python基础实战之猜年龄游戏


下一篇:SQLServer基础:Apply关键字用法介绍