def instant_order_deal(plat, special_product, clearance_goods, new_product_instant,orders):""":param plat: 要计算的平台:param special_product: 特定库龄产品,其他平台的,amazon的在下面单独读取:param clearance_goods: 清仓产品:param new_product: 新品:param orders: 订单:return:"""# 退款订单处理orders['订单总金额(包含客户运费、平台补贴)'] = orders.apply(lambda x: 0 if (x['订单类型'] == 'refund') else x['订单总金额(包含客户运费、平台补贴)'], axis=1)"中间特定sku处理毛利"# orders['毛利'] = orders.apply(lambda x: (x['平均采购价']* 0.4 + x['毛利']) if (x['产品代码'] == 'S4338867210')| (x['产品代码']=='S2130010010') else x['毛利'],axis=1)orders['毛利'] = orders.apply(lambda x: (x['毛利'] + 5) if (x['产品代码'] == 'S1416028410') | (x['产品代码'] == 'S1416028440') | (x['产品代码'] == 'S1416028470')  else x['毛利'], axis=1)"""折价商品毛利计算 + 额温枪"""depreciate = read_data().read_depreciate()orders['毛利'] = orders.apply(lambda x: (x['平均采购价'] * 0.4 * x['数量']  + x['毛利']) if (x['产品代码'] in depreciate) and x['订单类型'] == 'sale' else x['毛利'],axis=1)orders['平均采购价'] = orders.apply(lambda x: 0 if (x['订单类型'] == 'resend') else x['平均采购价'], axis=1)# 中英仓处理orders['仓库分类'] = orders.apply(lambda x: '中仓' if (x['发运仓库'] =='SH [上海奉贤仓]') | (x['发运仓库'] =='WZC [温州仓]') | (x['发运仓库'] =='SZC [深圳仓]') else '海外仓', axis=1)# 处理新品# if plat == 'ebay' or plat == 'shopee' or plat == 'amazon' :newproduct = read_data().read_newproduct()orders['仓库分类'] = orders.apply(lambda x: '新品' if (x['产品代码'] in newproduct) else x['仓库分类'], axis=1)#处理海运产品shipping = read_data().read_shipping()orders['仓库分类'] =orders.apply(lambda x: '海运产品' if(x['产品代码'] in shipping  and  x['仓库分类'] != '海外仓') else x['仓库分类'],axis=1)# 当月转清仓处理orders['仓库分类'] = orders.apply(lambda x: '特定库龄'if isClearance(x['付款时间'], x['产品代码'], clearance_goods) != None  else x['仓库分类'], axis=1)# 特定库龄处理orders['仓库分类'] = orders.apply(lambda x: '特定库龄' if (x['发运仓库'] == 'GSE [古斯美东仓]' and x['平台']!='ebay') else x['仓库分类'], axis=1)if plat == 'amazon':# amazon的特定库龄需要单独读取special_product_a = read_data().read_special_product(plat)special_product_as = read_data().read_special_product('amazon特殊')orders['仓库分类'] = orders.apply(lambda x: '特定库龄' if (x['产品代码'] in special_product_as) else x['仓库分类'], axis=1)orders['仓库分类'] = orders.apply(lambda x: '特定库龄' if ((x['发运仓库'] + x['产品代码']) in special_product_a) else x['仓库分类'], axis=1)else:special_product = read_data().read_special_product('其他平台')orders['仓库分类'] = orders.apply(lambda x: '特定库龄' if (x['产品代码'] in special_product) else x['仓库分类'], axis=1)orders['仓库分类']=orders.apply(lambda x:'稳定期' if (x['仓库分类']=='中仓')| (x['仓库分类']=='海外仓' )else x['仓库分类'],axis=1 )# 处理好仓库分类,接下来判断是否是开发新品orders = pd.merge(orders, new_product_instant, on='产品代码', how='left')orders['开发新品'] = orders['开发新品'].fillna('非开发新品')# 然后处理货值orders['货值'] = orders['数量'] * orders['平均采购价']# orders = pd.merge(orders,mask_instant, on='产品代码', how='left')# orders['口罩'] = orders['口罩'].fillna('非口罩')return orders

Python-apply(lambda x: )使用相关推荐

  1. python apply lambda if_在Pandas中使用Apply Lambda函数和多个if语句

    我试着根据像这样的数据框中一个人的大小推断出一个分类:Size 1 80000 2 8000000 3 8000000000 ... 我希望它看起来像这样:Size Classification 1 ...

  2. python apply lambda if_详解Python中的map、lambda和apply用法

    Hello大家好,欢迎来到[统计GO],本公众号内容主要针对数据分析的爱好者,不定期分享一些好用的数据分析工具和机器学习资料,以及一些求职必备技能,帮助大家花更少的时间学更多的知识. 今天为大家推荐的 ...

  3. Python apply函数

    1.介绍 apply函数是pandas里面所有函数中自由度最高的函数.该函数如下: DataFrame.apply(func, axis=0, broadcast=False, raw=False, ...

  4. python apply函数取数据中的后四位_python 实现rolling和apply函数的向下取值操作

    我就废话不多说了,大家还是直接看代码吧! import pandas as pd def get_under_rolling(df,window,user,name): df[name] = df[u ...

  5. python apply函数_python玄学之 apply函数的axis参数

    不知道小伙伴们学习python的dataframe时,是否遇到一个疑惑,apply参数axis的具体含义是什么? 官方文档解释如下:https://pandas.pydata.org/pandas-d ...

  6. python中lambda函数if用法-Python中关于Lambda函数的使用总结

    lambda表达式是一种匿名函数,对应python中的自定义函数def,是定义某个函数时比较高级的一种写法.作为python初学者,本文整理了lambda的一些基本用法和特点. lambda和def的 ...

  7. python的lambda表达式是什么?什么是回调函数?

    python的lambda表达式是什么?什么是回调函数? lambda lambda 表达式,通常是在需要一个函数,但是又不想费神去命名一个函数的场合下使用,也就是指匿名函数 lambda函数:首要用 ...

  8. pandas新字段(数据列)生成、使用np.where或者apply lambda函数结合if else生成新的字段,详解及实战

    pandas新字段(数据列)生成.使用np.where或者apply lambda函数结合if else生成新的字段,详解及实战 pandas apply用法: pandas apply方法的作用原理 ...

  9. Python中lambda表达式的优缺点及使用场景

    lambda表达式是什么? lambda 表达式是 Python 中创建匿名函数的一个特殊语法. 称 lambda 语法本身为 lambda 表达式,而它返回的函数我称之为 lambda 函数,或者称 ...

  10. python map lambda 分割字符串_python六剑客:map()、lambda()、filter()、reduce()、推导类表、切片...

    一:map():映射 map()函数在python2和python3中是区别的 python2中的定义:映射后,返回一个列表 >>> help(map) Help on built- ...

最新文章

  1. 如何运行 SAP Spartacus cypress 端到端测试
  2. PHP判断客户端的浏览器类型
  3. Python基础第一天
  4. Axure谷歌浏览器Chrome扩展程序下载及安装方法
  5. 01-路由跳转 安装less this.$router.replace(path) 解决vue/cli3.0语法报错问题
  6. Starling 性能优化方案
  7. 数据结构 Tricks(一)—— 父节点和左右孩子索引号之间的关系
  8. System.out.println 在idea控制台输出的中文乱码问题
  9. 传智播客 C/C++学习笔记 函数调用 模型
  10. 天翼云搭建socks5和搭建http
  11. 苹果手机突然没信号无服务器,iPhone突然没信号?3个方法让你迅速解决断线问题!...
  12. LaTeX 1软件下载安装
  13. 深度学习算法优化系列十 | 二值神经网络(Binary Neural Network,BNN)
  14. Mac下/usr目录
  15. 【Linux】linux 终端报Message from syslogd
  16. linux手动连接网络打印机驱动_中兴新支点Linux操作系统添加网络打印机的方法...
  17. NEO4J-链路预测算法03-优先链接算法(Preferential Attachment)应用场景简介
  18. 工业品销售,如何才能轻松赢得订单!
  19. HBuilder开发小程序,如何实现在微信开发者工具中实时更新
  20. unity | 输入汉字自动转换成带拼音(带声调)

热门文章

  1. colab的使用 详解(亲测)
  2. Linux arm 内核选项和busybox选项 加载tun模块 -- 创建/dev/tun 字符设备
  3. html 电视直播软件,智能电视装什么软件可以看电视直播,一个软件
  4. 有感于李开复演讲(2)
  5. CSS 清除默认样式模版
  6. 推荐算法遇到后悔药:评蚂蚁的ESCM2模型
  7. 用selenium 做个淘宝秒杀
  8. 互助系统定制开发-什么是互助系统?他是如何盈利的?
  9. 身体语言密码_《身体语言密码》,将个性分析应用到成功的三法则
  10. LayaAir2.13新特性:新增VR相关功能、渐变环境光、3D自定义分辨率、新的渲染命令、新的动画插值方式、新的粒子功能等等...