guopengfa
发布于 2020-05-27 / 825 阅读 / 0 评论 / 0 点赞

pandas按行求和

import pandas as pd
import datetime

if name == 'main':
data1 = pd.read_csv(r"W:\GUOPENGFA\fba_gross_require2020-03-26 06-28-19.csv")
data2 = pd.read_csv(r"D:\工作\钉钉文件\sal23_22225.csv")
sale_data = data1.update_time1[0]
sale_data = datetime.datetime.strptime(sale_data,"%Y-%m-%d %H:%M:%S").strftime("%Y-%m-%d")
data2_head = []
for i in data2.keys():
data2_head.append(i)
if i == sale_data:
break
data2 = data2[data2_head]
data2["30sale"] = data2.iloc[:,2:].sum(axis=1)
print(data2)
data2.to_csv(r"D:\Python\数据分析\rsult\outtext.csv")


评论