Consider the following dataset:
seq_id a b id
1 20 13 1
2 21 14 1
3 18 19 1
1 22 15 2
2 21 14 2
1 25 12 1
2 27 13 1
I need to sort my data set by id , however I have more than one group for the specific id. for example there are 2 groups of id 1. I need the following result:
seq_id a b id
1 20 13 1
2 21 14 1
3 18 19 1
1 25 12 1
2 27 13 1
1 22 15 2
2 21 14 2
I tried this script which is not correct:
sort = lambda x: sorted(x,reverse=False)
data = data.sort_values(by=['id'],ascending=True)
data.groupby('id').seq_id.apply(sort)
thanks for your comments.
Or is there any way to change the second group's name of id = 1 to separate them from each other. for example lets say, for the first group id = 1 and for the second group id = 1-1