Можете ли вы попробовать следующее:
import pandas as pd
cols = ['date', 'by', 'issue_number', 'group', 'events', 'deadline']
req_cols = ['events', 'deadline']
data = [
['2019-05-07', 'john', '113140', '@issue_closed', 'something different', ''],
['2019-05-08', 'david', '113140', '@task', 'something different', ''],
['2019-05-08', 'victor', '114761', '@task_result', 'something different', ''],
['2019-05-08', 'john', '114761', '@task', 'something different', '2019-05-10'],
['2019-05-08', 'david', '114761', '@task',
'something different', '2019-05-08'],
['2019-05-08', 'victor', '113140', '@task_result', 'something different', ''],
['2019-05-07', 'john', '113140', '@issue_created',
'something different', '2019-05-09'],
['2019-05-07', 'david', '113140', '@location', 'something different', ''],
['2019-05-07', 'victor', '113140', '@issue_closed', 'something different', 'done'],
['2019-05-07', 'john', '113140', '@task_result', 'something different', ''],
['2019-05-07', 'david', '113140', '@task',
'something different', '2019-05-10'],
]
df = pd.DataFrame(data, columns=cols)
df1 = df.groupby(['issue_number', 'group']).describe()[req_cols].droplevel(0, axis=1)['top']
df1.columns = req_cols
print(df1)
Вывод:
events deadline
issue_number group
113140 @issue_closed something different done
@issue_created something different 2019-05-09
@location something different
@task something different 2019-05-10
@task_result something different
114761 @task something different 2019-05-08
@task_result something different
Чтобы открыть файл excel
, вы можете сделать следующее:
df = pd.read_excel(excel_path, sheet_name=my_sheet)
req_cols = ['EVENTS', 'DEADLINE']
df1 = df.groupby(['ISSUE NUMBER', 'GROUP']).describe()[req_cols].droplevel(0, axis=1)['top']
df1.columns = req_cols
print(df1)