首页 > 作文

教你使用Pandas直接核算Excel中快递费用

更新时间:2023-04-09 03:03:37 阅读: 评论:0

一、确定核算规则

二、根据核算规则编写代码,生成核算列

# -*- coding:utf-8 -*- import pandas as pd from math import ceilimport osdef account(adress,weight):        if adress == "湖南":        if weight <= 3:            totel = 2.5        elif  (weight >= 3) and (weight<=5):            totel = 3.5 + ceil((weight-3))*1        el:            totel = ceil(weight)*1        return totel                elif adress in ["河北","天津","山西","浙江","江苏","安徽","福建","山东","江西","广东","广西","河南","湖北","陕西","四川","重庆","云南","贵州"]:        if weight <= 3:            totel = 2.5        elif  有余数的除法(weight >= 3) and (weight<=5):     12个月英语       totel = 3.5 + ceil((weight-3))*1        el:            totel = ceil(weight)*2         return totel        elif adress in ["深圳","北京","上海"]:        if weight <= 3:            totel = 3.3        elif  (weight >= 3) and (weight<=5):            totel = 3.5 + ceil((weight-3))*1.5        el:            totel = ceil(weight)*2外国名人        return totel              挑怎么读  elif adress in ["海南","辽宁","黑龙江","吉林"]:        if weight <= 3:            totel = 2.5        elif  (weight >= 3) and (weight<=5):            totel = 3.5 + ceil((weight-3))*2.5        el:            totel = ceil(weight)*3        return totel    elif adress in ["内蒙古","甘肃","宁夏","青海"]:        if  weight <= 1:            totel 2016安徽卫视国剧盛典= 9        el:            totel = 9 + ceil(weight-1)*6         return totel    elif adress == "新疆":        if  weight <= 1:            totel = 15        el:            totel = 15 + ceil(weight-1)*12         return totel    elif adress == "西藏":        if  weight <= 1:            totel = 16        el:            totel = 15 + ceil(weight-1)*18         return totel        el:        print("你输入的省份不合法!!!")    file_path = input("请输入文件路径:")   sheet_name = input("请输入工作簿名称:")pf = pd.read_excel(file_path,sheet_name=sheet_name)#获取省份一列pro = pf["省份"].values.tolist()#获取重量一列wt = pf["重量"].values.tolist()#核算列totel = []for p,w in zip(pro,wt):    print(p,w)    totel.append(account(p,w))pf["最新核算结果"] = totelfile_name = os.path.baname(file_path)pf.to_excel(os.path.join(os.path.dirname(file_path),os.path.baname(file_path).split(".")[0]+sheet_name+"最新核算结果"+".xlsx"))

三、输入账单,进行核算。

在脚本文件目录中执行pyinstaller -f hesuan.py 进行打包exe文件,如果为安装pyinstaller,使用pip install pyinstaller 安装。点击运行打包后的exe文件,输入文件的路径名和sheet名,就可以进行自动核算,脚本运行完成后会自动保存一个新的excel文件。

到此这篇关于教你使用pandas直接核算excel中快递费用的文章就介绍到这了,更多相关pandas核算excel中快递费用内容请搜索www.887551.com以前的文章或继续浏览下面的相关文章希望大家以后多多支持www.887551.com!

本文发布于:2023-04-09 03:03:35,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/zuowen/7069e8b5df73e59903f891eabd29465e.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

本文word下载地址:教你使用Pandas直接核算Excel中快递费用.doc

本文 PDF 下载地址:教你使用Pandas直接核算Excel中快递费用.pdf

标签:文件   省份   请输入   安徽
相关文章
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图