当前位置 : 主页 > 编程语言 > python >

python_折扣优惠数据处理

来源:互联网 收集:自由互联 发布时间:2022-07-19
python_折扣优惠数据处理 #提取优惠券的相关特征 def calc_discount_rate ( s ): s = str ( s ) s = s . split ( ':' ) if len ( s ) == 1 : return float ( s [ 0 ]) else : return 1.0 - float ( s [ 1 ]) / float ( s [ 0 ]) def get_di


python_折扣优惠数据处理

python_折扣优惠数据处理_数据处理

#提取优惠券的相关特征

def calc_discount_rate(s):
s = str(s)
s = s.split(':')
if len(s) == 1:
return float(s[0])
else:
return 1.0-float(s[1])/float(s[0])
def get_discount_man(s):
s = str(s)
s = s.split(':')
if len(s)==1:
return 'null'
else:
return int(s[0])
def get_discount_jian(s):
s = str(s)
s = s.split(':')
if len(s) == 1:
return 'null'
else:
return int(s[1])

def is_man_jian(s):
s = str(s)
s = s.split(':')
if len(s)==1:
return 0
else:
return 1

#显示满了多少钱后开始减
dataset3['discount_man'] = dataset3.discount_rate.apply(get_discount_man)
#显示满减的减少的钱
dataset3['discount_jian'] = dataset3.discount_rate.apply(get_discount_jian)
#返回优惠券是否是满减券
dataset3['is_man_jian'] = dataset3.discount_rate.apply(is_man_jian)
#显示打折力度
dataset3['discount_rate'] = dataset3.discount_rate.apply(calc_discount_rate)


上一篇:python_数据集重命名&删除空行
下一篇:没有了
网友评论