I have a pyspark dataframe which looks like below:
col1 | col2 | col3
R a abc
R a abc
G b def
G b def
G b def
and I want to add new column to it which will generate the index for these unique rows as per the count like below:
col1 | col2 | col3 | new_column
R a abc 0
R a abc 1
G b def 0
G b def 1
G b def 2
Please help me to generate this new column using pyspark.
Thanks in advance!