预测1120.xlsx

做了一些修改,之前写的乱七八糟,看下是否说清楚了,谢谢~

0 0 0

wangxishi

2020-11-20

python 做预测

~P0ZWJY[QP2ZM[I%ZZD$$A0.png

2 0 0

Dragon男爵

2020-11-20

Python的快捷键有哪些

image.png

0 0 0

wangxishi

2020-11-18

用python解决装箱问题

#导入库
import pandas as pd
#导入数据生成数据框
box=pd.read_excel("D:\\360安全浏览器下载\\金额包.xlsx",skiprows=0,usecols=[0,1,3,4,5])
waitbox=pd.read_excel("D:\\360安全浏览器下载\\待装箱清单.xlsx",skiprows=0,usecols=[0,1])
#waitbox为等待被分箱的数据


#对数据框waitbox,按照金额从到小的顺序进行排序
waitbox.sort_values(by="金额",ascending=False,inplace=True)
#重设数据框waitbox索引
waitbox.reset_index(inplace=True)
#准备waitbox的相关指标
waitbox["装箱编号"]=""

#准备box的相关指标
box["当前金额"]=0
box["剩余空间"]=box["上限"]-box["当前金额"]
box["为达下限还需要补充"]=box["下限"]-box["当前金额"]
box["订单集和"]=box["ID"].map(lambda x:list())
box["箱子是否达下限"]=False
#将箱子按照箱子上限进行排序,升序排列
box.sort_values(by="为达下限还需要补充",ascending=False,inplace=True)




#然后对每笔订单进行箱子分配
rows=waitbox.shape[0]
i=0   #用i表示第几个订单
while i<rows:
    print("现在对第%d个订单进行分配"%i,end="")


    #检验第i个物品是否可以放在根据"为达下限还需要补充"降序排序的第一个箱子

    if box.loc[0,"剩余空间"]>waitbox.loc[i,"金额"]:
        print(box.loc[0,"ID"])
        box.loc[0,"当前金额"]=box.loc[0,"当前金额"]+waitbox.loc[i,"金额"]
        box.loc[0,"剩余空间"]=box.loc[0,"上限"]-box.loc[0,"当前金额"]
        box.loc[0,"为达下限还需要补充"]=box.loc[0,"下限"]-box.loc[0,"当前金额"]
        waitbox.loc[i,"装箱编号"]=box["ID"][0]
        新增物品=(waitbox.loc[i,"ID"],waitbox.loc[i,"金额"])
        box["订单集和"][0]=box["订单集和"][0]+[新增物品]
        if box.loc[0,"当前金额"]>=box.loc[0,"下限"]:
            box.loc[0,"箱子是否达下限"]=True
        #对各个箱子的剩余容量进行排序
        box.sort_values(by=["箱子是否达下限","为达下限还需要补充"],ascending=[True,False],inplace=True)
        box.reset_index(inplace=True,drop=True)
        
    else:
        print("第%d个物品没有办法再装了"%i,"金额为",waitbox.loc[i,"金额"],"准备装箱代码为",box.loc[0,"ID"],sep="")
        break
    
    
    i=i+1
    



box.to_excel("D:\\分箱后每个箱子的情况.xlsx")
waitbox.to_excel("D:\\每笔订单分箱结果.xlsx")


0 0 0

wangxishi

2020-11-18

用python解决装箱问题