危险代码
import os
import pandas as pd
from pandas.core.frame import DataFrame
pd.set_option('display.max_rows', None)
pd.set_option('display.max_columns', None)
pd.set_option('mode.chained_assignment', None)
Aaipay_path = "F:\\zhifubao\\Aaipay.csv"
Aaipay_data = pd.read_csv(Aaipay_path, dtype=object, encoding='GBK',names=["zwlsh","ywlsh","shddh","spmc","fssj","dfzh","srje","zcje","zhye","jyqd","ywlx","bz","ywms","ywzdly","ywjcddh","ywddh"])
Aaipay_data["order_new"] = Aaipay_data["ywjcddh"]
oms_data["order"] = oms_data["wdddh"]
Aaipay_data["order"] = Aaipay_data["order_new"].apply(lambda x:str(x).split('\t')[0])
print(2)
order_aipay = list(set(Aaipay_data["order"].values))
order_aipay = list(filter(None,order_aipay))
order_oms = list(set(oms_data["order"].values))
new_aipay_one = pd.DataFrame()
new_aipay_zero = pd.DataFrame()
new_oms_one = pd.DataFrame()
new_oms_zero = pd.DataFrame()
for i in order_aipay:
merge_aipay = Aaipay_data[Aaipay_data["order"]==i][:]
merge_aipay[["srje"]] = merge_aipay[["srje"]].astype(float)
if merge_aipay.shape[0] > 1:
income = merge_aipay["srje"].sum()
list_aipay = [[i,income]]
new_aipay_one = new_aipay_one.append(list_aipay,ignore_index=True)
else:
new_aipay_zero = pd.concat([merge_aipay,new_aipay_zero], ignore_index=True)
try:
new_aipay_zero = new_aipay_zero.loc[:,["order","srje"]]
except:
pass
try:
new_aipay_one.columns = ["order","srje"]
except:
pass
aipay_end = pd.concat([new_aipay_one,new_aipay_zero],ignore_index=True)
aipay_end.dropna(axis=0,how='any',inplace=True)
aipay_end = aipay_end[aipay_end["order"] != ""][:]
aipay_end.to_excel("E:\\aipay\\aipay.xlsx",index=False,encoding='GBK')