def tranf(x): if x.startswith(('在线','邮局','定向','公司','京豆','限品','积分','高校')): x= 'a' elif x.startswith(('上门','货到','前台')): x = 'b' elif x.startswith(('分期','白条')): x = 'c' elif x.startswith(('混合')): x = 'd' return x train_order_later['type_pay1'] = train_order_later['type_pay'].apply(tranf)train_order_later['type_pay1'].value_counts()
def tranf(x):
train_order_later['type_pay1'] = train_order_later['type_pay'].apply(tranf)
train_order_later['type_pay1'].value_counts()