I have this dataframe
df1 = pd.DataFrame(data = {'id':[1,1,1,1,2,2,3],'task':[12,32,12,54,64,21,52]})
I want to group by id
and change task
values respectively like this
id task
0 1 1A
1 1 2A
2 1 3A
3 1 4A
4 2 1B
5 2 2B
6 3 1C
I have done this so far
df1['task']=df1.groupby('id')['task'].transform(lambda x : x.factorize()[0]+1)
Which gives me
id task
0 1 1
1 1 2
2 1 1
3 1 3
4 2 1
5 2 2
6 3 1
How can I get the alphabets and secondly why in id
1 the task sequence is 1213 but not 1234?