I was puzzled by the issue just like as below.
DataFrame=
i have the DataFrame data and using the DataFrame.groupby(["Month","Repair_type","Repair_State"]).size()
and the result is just like below graph.
Noted: I wanted to add the data as "Repair_type[just_for_sample]-->Repair_State[End of process]" in January, example as below
Month=['January', 'January', 'January', 'January', 'January', 'January', 'January', 'January', 'January', 'January', 'January', 'January', 'January', 'January', 'January', 'January', 'January', 'January', 'January', 'January', 'January', 'January', 'January', 'January', 'January', 'January', 'January', 'January', 'January', 'January', 'January', 'January', 'January', 'January', 'January', 'January', 'January', 'February', 'February', 'February', 'February', 'February', 'February', 'February', 'February', 'February', 'February', 'February', 'February', 'February', 'February', 'February', 'February', 'February', 'February', 'February', 'February', 'February', 'February', 'February', 'February', 'February', 'February', 'March', 'March', 'March', 'March', 'March', 'March', 'March', 'March', 'March', 'March', 'March', 'March', 'March', 'March', 'March', 'March', 'March', 'March', 'March', 'March', 'March', 'March', 'March', 'March', 'March', 'March', 'March', 'March', 'March', 'March', 'March', 'March', 'April', 'April', 'April', 'April', 'April', 'April', 'April', 'April', 'April', 'April', 'April', 'April', 'April', 'April', 'April', 'April', 'April', 'April', 'April', 'April', 'April', 'April', 'April', 'April', 'April', 'April', 'April', 'April', 'April', 'April', 'April', 'April', 'April', 'April', 'May', 'May', 'May', 'May', 'May', 'May', 'May', 'May', 'May', 'May', 'May', 'May', 'May', 'May', 'May', 'May', 'May', 'May', 'May', 'May', 'May', 'May', 'May', 'May', 'May', 'May', 'May', 'May', 'May', 'May', 'May', 'May', 'May', 'June', 'June', 'June', 'June', 'June', 'June', 'June', 'June', 'June', 'June', 'June', 'June', 'June', 'June', 'June', 'June', 'June', 'June', 'June', 'June', 'June', 'June', 'June', 'June', 'June', 'June', 'June', 'June', 'June', 'June', 'June']
Repair_type=['units_return', 'units_return', 'units_return', 'units_return', 'units_return', 'units_return', 'units_return', 'units_return', 'pre_unit_ship', 'pre_unit_ship', 'pre_unit_ship', 'pre_unit_ship', 'pre_unit_ship', 'pre_unit_ship', 'pre_unit_ship', 'pre_unit_apply', 'pre_unit_apply', 'pre_unit_apply', 'pre_unit_apply', 'pre_unit_apply', 'pre_unit_apply', 'nor_unit_ship', 'nor_unit_ship', 'nor_unit_ship', 'nor_unit_ship', 'nor_unit_ship', 'nor_unit_ship', 'nor_unit_ship', 'nor_unit_ship', 'nor_unit_ship', 'quick_repari_unit', 'quick_repari_unit', 'quick_repari_unit', 'quick_repari_unit', 'quick_repari_unit', 'quick_repari_unit', 'quick_repari_unit', 'units_return', 'units_return', 'units_return', 'units_return', 'units_return', 'pre_unit_ship', 'pre_unit_ship', 'pre_unit_ship', 'pre_unit_ship', 'pre_unit_ship', 'pre_unit_ship', 'pre_unit_apply', 'pre_unit_apply', 'pre_unit_apply', 'pre_unit_apply', 'nor_unit_ship', 'nor_unit_ship', 'nor_unit_ship', 'nor_unit_ship', 'nor_unit_ship', 'quick_repari_unit', 'quick_repari_unit', 'quick_repari_unit', 'quick_repari_unit', 'quick_repari_unit', 'just_for_sample', 'units_return', 'units_return', 'units_return', 'units_return', 'units_return', 'units_return', 'units_return', 'units_return', 'pre_unit_ship', 'pre_unit_ship', 'pre_unit_ship', 'pre_unit_ship', 'pre_unit_ship', 'pre_unit_apply', 'pre_unit_apply', 'pre_unit_apply', 'pre_unit_apply', 'nor_unit_ship', 'nor_unit_ship', 'nor_unit_ship', 'nor_unit_ship', 'nor_unit_ship', 'nor_unit_ship', 'nor_unit_ship', 'quick_repari_unit', 'quick_repari_unit', 'quick_repari_unit', 'quick_repari_unit', 'quick_repari_unit', 'quick_repari_unit', 'quick_repari_unit', 'just_for_sample', 'units_return', 'units_return', 'units_return', 'units_return', 'units_return', 'units_return', 'units_return', 'units_return', 'units_return', 'pre_unit_ship', 'pre_unit_ship', 'pre_unit_ship', 'pre_unit_ship', 'pre_unit_ship', 'pre_unit_ship', 'pre_unit_ship', 'pre_unit_apply', 'pre_unit_apply', 'pre_unit_apply', 'pre_unit_apply', 'pre_unit_apply', 'nor_unit_ship', 'nor_unit_ship', 'nor_unit_ship', 'nor_unit_ship', 'nor_unit_ship', 'nor_unit_ship', 'nor_unit_ship', 'quick_repari_unit', 'quick_repari_unit', 'quick_repari_unit', 'quick_repari_unit', 'quick_repari_unit', 'just_for_sample', 'units_return', 'units_return', 'units_return', 'units_return', 'units_return', 'units_return', 'units_return', 'units_return', 'units_return', 'pre_unit_ship', 'pre_unit_ship', 'pre_unit_ship', 'pre_unit_ship', 'pre_unit_ship', 'pre_unit_ship', 'pre_unit_ship', 'pre_unit_apply', 'pre_unit_apply', 'pre_unit_apply', 'pre_unit_apply', 'nor_unit_ship', 'nor_unit_ship', 'nor_unit_ship', 'nor_unit_ship', 'nor_unit_ship', 'nor_unit_ship', 'nor_unit_ship', 'quick_repari_unit', 'quick_repari_unit', 'quick_repari_unit', 'quick_repari_unit', 'quick_repari_unit', 'just_for_sample', 'units_return', 'units_return', 'units_return', 'units_return', 'units_return', 'units_return', 'units_return', 'units_return', 'pre_unit_ship', 'pre_unit_ship', 'pre_unit_ship', 'pre_unit_ship', 'pre_unit_ship', 'pre_unit_ship', 'pre_unit_apply', 'pre_unit_apply', 'pre_unit_apply', 'pre_unit_apply', 'pre_unit_apply', 'nor_unit_ship', 'nor_unit_ship', 'nor_unit_ship', 'nor_unit_ship', 'nor_unit_ship', 'quick_repari_unit', 'quick_repari_unit', 'quick_repari_unit', 'quick_repari_unit', 'quick_repari_unit', 'quick_repari_unit', 'quick_repari_unit']
Repair_State=['obsolete', 'Overhauled', 'To be shipped', 'To be returned', 'Goods to be received', 'Under maintenance', 'End of process', 'draft', '445', 'obsolete', 'Received goods', 'To be reviewed', 'To be returned', 'Under maintenance', 'End of process', 'obsolete', 'To be warehoused', 'Goods to be prepared', 'To be reviewed', 'Receiving spare parts', 'End of process', '235', '245', 'Warehoused', 'obsolete', 'Goods to be prepared', 'To be reviewed', 'To be returned', 'Under maintenance', 'End of process', '635', 'obsolete', 'To be returned', 'Warehoused', 'Under maintenance', 'End of process', 'draft', 'obsolete', 'To be returned', 'Goods to be received', 'Under maintenance', 'End of process', 'Spare parts to be repaired', 'obsolete', 'Received goods', 'Overhauled', 'To be returned', 'End of process', 'obsolete', 'To be reviewed', 'Receiving spare parts', 'End of process', '235', 'Warehoused', 'obsolete', 'To be returned', 'End of process', '635', 'Warehoused', 'obsolete', 'To be returned', 'End of process', 'Under maintenance', 'obsolete', 'Received goods', 'Overhauled', 'To be reviewed', 'To be returned', 'Goods to be received', 'End of process', 'draft', 'obsolete', 'Received goods', 'To be returned', 'Under maintenance', 'End of process', 'obsolete', 'Goods to be received', 'Receiving spare parts', 'End of process', '235', 'Warehoused', 'obsolete', 'To be returned', 'Under maintenance', 'End of process', 'draft', '635', '645', 'Warehoused', 'obsolete', 'To be returned', 'Under maintenance', 'End of process', 'Warehoused', 'obsolete', 'Received goods', 'Overhauled', 'To be shipped\n', 'To be reviewed', 'To be returned', 'Goods to be received', 'Under maintenance', 'End of process', 'obsolete', 'Received goods', 'Overhauled', 'To be returned', 'Goods to be received', 'Under maintenance', 'End of process', 'obsolete', 'To be reviewed', 'Goods to be received', 'Receiving spare parts', 'End of process', 'Warehoused', 'obsolete', 'To be warehoused', 'To be reviewed', 'To be returned', 'Under maintenance', 'End of process', 'Warehoused', 'obsolete', 'To be returned', 'Under maintenance', 'End of process', 'Under maintenance', '1010', 'obsolete', 'Overhauled', 'To be reviewed', 'To be returned', 'Goods to be received', 'Under maintenance', 'End of process', 'draft', 'obsolete', 'Received goods', 'To be shipped\n', 'To be returned', 'Goods to be received', 'Under maintenance', 'End of process', 'obsolete', 'To be overhauled', 'Receiving spare parts', 'End of process', 'Warehoused', 'obsolete', 'To be reviewed', 'To be returned', 'Warehoused', 'Under maintenance', 'End of process', 'Warehoused', 'obsolete', 'To be returned', 'Under maintenance', 'End of process', 'Warehoused', 'obsolete', 'Received goods', 'Overhauled', 'To be shipped\n', 'To be returned', 'Goods to be received', 'Under maintenance', 'End of process', 'obsolete', 'Received goods', 'To be returned', 'Goods to be received', 'Under maintenance', 'End of process', 'Prepare spare parts', 'obsolete', 'Goods to be received', 'Receiving spare parts', 'End of process', 'Warehoused', 'obsolete', 'To be returned', 'Under maintenance', 'End of process', 'Warehoused', 'obsolete', 'To be reviewed', 'To be returned', 'Under maintenance', 'End of process', 'draft']
count=[6, 4, 1, 13, 175, 2, 15, 1, 1, 2, 2, 2, 9, 1, 14, 3, 1, 1, 4, 17, 30, 16, 1, 35, 5, 3, 1, 43, 9, 81, 8, 2, 22, 1, 2, 53, 1, 8, 7, 174, 3, 8, 1, 1, 7, 1, 3, 9, 1, 5, 12, 4, 5, 31, 2, 34, 29, 6, 1, 1, 6, 39, 1, 8, 2, 2, 6, 4, 242, 15, 2, 1, 10, 8, 2, 6, 5, 1, 21, 24, 3, 52, 4, 69, 6, 62, 1, 5, 1, 3, 1, 21, 8, 82, 1, 26, 1, 2, 1, 1, 12, 255, 3, 26, 1, 15, 1, 9, 1, 1, 11, 4, 2, 1, 27, 35, 40, 12, 2, 1, 76, 4, 123, 4, 4, 13, 4, 94, 1, 1, 15, 3, 1, 8, 227, 5, 20, 1, 1, 12, 1, 7, 1, 3, 8, 6, 1, 25, 27, 34, 6, 1, 65, 1, 5, 90, 40, 7, 22, 12, 37, 1, 11, 1, 3, 1, 5, 213, 3, 14, 1, 10, 6, 1, 2, 8, 1, 2, 2, 54, 27, 11, 6, 66, 6, 133, 66, 4, 1, 21, 2, 7, 2]
df1 = pd.DataFrame({'Month': Month,
'Repair_type': Repair_type,
'Repair_State': Repair_State,
'count':count})
print(df1.groupby(['Month','Repair_type','Repair_State']).size())
and the result show as below:
Month Repair_type Repair_State count
January 587
nor_unit_ship 194
235 16
245 1
End of process 81
Goods to be prepared 3
obsolete 5
To be returned 43
To be reviewed 1
Under maintenance 9
Warehoused 35
pre_unit_apply 56
pre_unit_ship 31
quick_repari_unit 89
units_return 217
February 399
just_for_sample 1
Under maintenance 1
nor_unit_ship 101
235 5
End of process 29
obsolete 2
To be returned 34
Warehoused 31
pre_unit_apply 22
pre_unit_ship 22
quick_repari_unit 53
units_return 200
I need to add the just_for_sample data Under maintenance in January as February.