导入并获取数据集
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
df = pd.DataFrame({'DaysExperienceTask': ['7', '8', '2', '6', '9', '3'],
'TaskType': ['Informatica', 'Spotfire', 'Python', 'Spotfire', 'Informatica', 'Powerbi'],
'User': ['Vaughad', 'Kodams', 'Sreddy', 'Kodams', 'Vaughad', 'Sreddy']})
print(df)
DaysExperienceTask TaskType User
0 7 Informatica Vaughad
1 8 Spotfire Kodams
2 2 Python Sreddy
3 6 Spotfire Kodams
4 9 Informatica Vaughad
5 3 Powerbi Sreddy
这是我想要得到的结果
DaysExperienceTask TaskType User TaskCount
0 7 Informatica Vaughad 16
1 8 Spotfire Kodams 14
2 2 Python Sreddy 2
3 6 Spotfire Kodams 14
4 9 Informatica Vaughad 16
5 3 Powerbi Sreddy 3
我想对每个“ TaskType”的“ DaysExperienceTask”求和,
确保它对应于正确的“用户”,然后显示在新列“ TaskCount”中。这应该告诉我用户在每个任务上有多少经验。
任何帮助是极大的赞赏!谢谢!