过滤CSV文件后,我得到了以下代码:import pandas as pddata1=pd.read_csv('Report1.csv',encoding = "ISO-8859-1")df = data1[pd.notnull(data1['Assignee'])]group=(df['type'].value_counts())print(group)但是当 csv 看起来像这样时,我被困在这里:Type Assignee statusrequest madan assignedris madan resolvedrequest kumar resolvedincide kumar assignedincide madan assigned我需要输出为:madan has 2 assigned and 1 resolved (1 request, 1 ris , 1 inciden)kumar has 1 assigned and 1 resolved (1 request , 1 incident )请帮忙。提前致谢。
1 回答
阿晨1998
TA贡献2037条经验 获得超6个赞
你可以用crosstab在pandas
pd.concat([pd.crosstab(df.Assignee, df.status), pd.crosstab(df.Assignee, df.Type)], axis=1)
输出:
assigned resolved incide request ris
Assignee
kumar 1 1 1 1 0
madan 2 1 1 1 1
添加回答
举报
0/150
提交
取消