Just adding some more operations on data. Suppose we have a dataframe df
, we can do several operations to get desired outputs
ID cost tax label
1 216590 1600 test
2 523213 1800 test
3 250 1500 experiment
(df['label'].value_counts().to_frame().reset_index()).sort_values('label', ascending=False)
will give sorted
output of labels as a dataframe
index label
0 test 2
1 experiment 1