Click here to Skip to main content
15,881,938 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have this Dataset:
Accession Number	Value
0	0001754960-22-000233	258
1	0001754960-22-000233	254
2	0001754960-22-000233	254
3	0001754960-22-000233	259
4	0001754960-22-000233	3753
...	...	...
2568329	0000950123-22-007614	13660
2568330	0000950123-22-007614	25464
2568331	0000950123-22-007614	1368
2568332	0000950123-22-007614	31956
2568333	0000950123-22-007614	10224


I want Output Where, every Accession Number has S.no which will assign the values, for eg: Accesssion Number -0001754960-22-000233 will have S.no as 1 for all rows, Next Accession will have 2 for all it's rows and so on.


Somewhat like this:
Accession Number	Value	S.No
0	0001754960-22-000233	1	
1	0001754960-22-000233	1	
2	0001754960-22-000233	1
3	0001754960-22-000233	1
4	0001754960-22-000233	1	
5	0001754960-22-000233	1


What I have tried:

df5['Index']=df5.groupby('Accession Number')['Accession Number'].transform('count')
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900