来自列表的总和的熊猫数据框

时间:2020-10-26 15:39:07

标签: python pandas

下午好! 我需要从列表中添加间隔,并创建一个熊猫数据框,然后将数据加载到数据库中。金额有问题。我需要从一个列表中添加所有时间戳并获取总和,然后由受让人客户端创建另一列称为“时间”,并将其插入数据库中,但是我不知道如何添加它们('198:18:57' +'0:0:0'等)。

from sqlalchemy import create_engine
import pandas as pd
from pandas import DataFrame

engine = create_engine('postgresql+psycopg2://jira_user:jira_user@localhost:5432/jira_test')
data = [['CRT-33', '198:18:57', '0:0:0', '0:0:0', '0:0:0', '0:0:0', 'CRT-369'], ['CRT-34', '0:0:0', '0:0:0', '0:0:0', '0:0:0', '167:17:22','CRT-355']]
header = ["Key", "Time_in_Resolved", "Time_in_InfoRequest", "Time_in_Postponed","Time_in_PM_Review","Time_in_Rejected"]
data_c = []
data_sum=[]

#delete last value from query
for i in data:
    data_c.append((i[:-1]))
#delete first colum for calculating
for i in data_c:
    data_sum.append((i[1:]))
#the sum of all data from the list ? 

print(data_c)
dat = DataFrame(data_c, columns=header)
dat.to_sql('correction_an', con=engine, schema='public', index=False, if_exists='append')

0 个答案:

没有答案