0

I have a dataframe with this structure

v1 v2
1  2
2  3
2  1
3  4
4  5
5  3 

I would like to add another column to identify if v1 is duplicate to get something like this

v1 v2 dup
1  2  1
2  3  1
2  1  2
3  4  1
4  5  1 
5  3  1 

So basically column dup it points out with a 2 that v1 = 2 is duplicated if v1 has a value repeated 3 times then you'll get values of 1, 2, 3 for each occurrence in the dup column.

Thx!

EGM8686
  • 1,492
  • 1
  • 11
  • 22

0 Answers0