import pandas as pd#匹配可发库存
1.

import os
lst=os.listdir(r'E:\每日必做\琪琪小象库存')
lst1=[]
for i in lst:
if i[:2] == '12':
print(i)
path='E:/每日必做/琪琪小象库存/'+i
a=pd.read_excel(path,sheetname='Sheet1')
a['日期']=i.replace('.','/').replace('xlsx','')
lst1.append(a[['商家编码','日期','可发库存']])
print(i)
print(a.sheet_names)
df_user = pd.concat(lst1, axis=0, ignore_index=True)
df_user.to_excel(r'C:\Users\Administrator\Desktop\12月库存.xlsx')

2.

  

df = pd.read_excel(r'C:\Users\Administrator\Desktop\12月退款分析\12月订单.xlsx')
kc = pd.read_excel(r'C:\Users\Administrator\Desktop\12月退款分析\12月库存.xlsx')
aa = pd.DataFrame((str(x).split(' ') for x in df['付款时间']), index=df.index, columns=['日期1', '付款时刻'])
df['日期'] =aa['日期1']
bb = pd.DataFrame((str(x).split(' ') for x in kc['日期']), index=kc.index, columns=['日期1', '付款时刻'])
kc['日期'] = bb['日期1']
df['商家时间']=df['日期']+df['商家编码']
kc['商家时间']=kc['日期']+kc['商家编码']
df = pd.merge(df, kc[['商家时间', '可发库存']], how='left', on=['商家时间'])
for i in df.index:
if df['可发库存'].at[i]<15:
df['可发库存'].at[i]=0
elif df['可发库存'].at[i]>=15:
df['可发库存'].at[i]=1
df.to_excel(r'C:\Users\Administrator\Desktop\12月退款分析\12月订单校对_1.xlsx')#另存为

3.

df = pd.read_excel(r'C:\Users\Administrator\Desktop\12月退款分析\12月订单.xlsx')
ys_order=pd.read_excel(r'C:\Users\Administrator\Desktop\12月退款分析\12月原始订单.xlsx')#读取原始订单
ys_order.drop_duplicates(subset='原始单号', keep='first', inplace=True)#删除原始订单重复值
df.rename(columns={'子单原始单号':'原始单号'},inplace=True)
new_order=pd.merge(df,ys_order[['原始单号','支付时间']],how='left',on='原始单号')
new_order.to_excel(r'C:\Users\Administrator\Desktop\12月退款分析\12月订单校对.xlsx')

4.

df=new_order
new_order=df[df['订单来源']=='接口抓取']
# print('总销量:'+str(df['下单数量'].sum()))#显示总销量

df = pd.read_excel(r'C:\Users\lenovo\Desktop\aa\12.xlsx')
kc = pd.read_excel(r'C:\Users\lenovo\Desktop\aa\12月库存.xlsx')
bb = pd.DataFrame((str(x).split(' ') for x in kc['日期']), index=kc.index, columns=['日期1', '付款时刻'])
kc1 = pd.merge(kc, bb, left_index=True, right_index=True)
aa = pd.DataFrame((str(x).split(' ') for x in df['付款时间']), index=df.index, columns=['日期1', '付款时刻'])
df = pd.merge(df, aa, left_index=True, right_index=True)
df['日期']=aa['日期1']
kc['商家时间']=kc1['日期1']+kc1['商家编码']
df['商家时间']=df['日期']+df['商家编码']
result = pd.merge(df, kc[['日期', '商家编码','可发库存','商家时间']], how='left', on='商家时间') new_order=df.merge(ys_order[['原始单号','支付时间']],how='left',left_on='子单原始单号',right_on='原始单号',sort=False)#vlookup原始单号的付款时间
df=new_order
#更改付款时间
for i in df.index:
if df['付款时间'].at[i]!=df['支付时间'].at[i]:
print('on')
df['付款时间'].at[i]=df['支付时间'].at[i]
# print(df[['付款时间','支付时间']])
df.to_excel(r'C:\Users\lenovo\Desktop\订单1.xlsx')#另存修改付款时间后的文件

caog的更多相关文章

  1. java基础学习总结——this关键字

    一.this关键字

  2. (十二)this关键字

    ---摘自孤傲苍狼博客 一.this关键字 this是一个引用,它指向自身的这个对象. 看内存分析图:

  3. java基础—this关键字

    一.this关键字

随机推荐

  1. PAT 1152 Google Recruitment

    1152 Google Recruitment (20 分)   In July 2004, Google posted on a giant billboard along Highway 101 ...

  2. 拷贝的表的SQL语句 SELECT INTO 和 INSERT INTO SELECT的用法与区别

    一.select   into  from 语句形式为:Insert into Table2(field1,field2,...) select value1,value2,... from Tabl ...

  3. 正试图在os加载程序锁内执行托管代码。不要尝试在DllMain或映像初始化函数内运行托管代码 问题解决方法

    方法一把vs菜单的 调试->异常->Managed Debuggin Assistants->LoaderLock

  4. 1-TwoSum(简单)

    Description: Given an array of integers, return indices of the two numbers such that they add up to ...

  5. linux 7.2安装扩展redis

    unzip phpredis-php7.zip cd phpredis-php7 /usr/local/php7./bin/phpize ./configure --with-php-config=/ ...

  6. apk文件二维码微信无法识别 APP在微信中二维码扫描无法下载的解决方案

    现在微信分享的功能很多,从分享的链接下载apk安卓包是很正常的,但是微信不让下载apk包,只能通过浏览器来下载,但是这要给用户一个提示吧,不然用户不知道 下面我们来实现,引导用户通过浏览器来下载apk ...

  7. kd-tree题目总结

    在竞赛中,kd-tree一般只用于平面,很少有高于二维的情况. 在随机情况下,kd-tree的复杂度为O(NlogN),但会被极端数据卡到平方级别. 总而言之,就是优美的暴力. 查询时,通过估价函数进 ...

  8. elasticsearch基本使用

    elasticsearch 是java对lucence的封装,所以需要事先安装java. 它适用于全文索引,便捷的分布式,主要原理就是倒排索引.一般搜索某个关键字,是通过在一篇篇文章中查找这个关键字, ...

  9. 使用Python统计函数绘制简单图形matplotlib

    1.bar() -- 绘制柱状图 plt.bar(x,y,align="center",color="b",tick_label=["a", ...

  10. JDBCUtils——DBCP

    需要导入的包: mysql-connector-java-5.1.37-bin.jar commons-dbcp-1.4.jar commons-pool-1.6.jar 需要添加/配置的配置文件: ...