Hi I have a data frame which appears like below. I want to group-by data frame with id and then count number of success/failure/partial in a data frame.
dict_1 = {"Id" : [1, 1, 1, 2, 2, 3, 3, 4, 4, 4],
"Output" : ["Success", "Success", "Failure", "Success", "Success", "Failure", "Failure",
"Success", "Failure", "Partial"]}
test_dict = pd.DataFrame(dict_1)
And below is the output I am expecting
dict_2 = {"Id" : [1, 2, 3, 4],
"Success_Count" : [2, 2, 0, 1],
"Failure_Count" : [1, 0, 2, 1],
"Partial_Count" : [0, 0, 0, 1]}
output_dict = pd.DataFrame(dict_2)
I have tried grouping the data based on id column and then applying filter() function in the groupby data frame but it is not working.
Can someone help me with the above query.