I want to Create a column named "id" which will have row numbers to be used in final pair generation. "id" column
I did it in python using below way. can anyone suggest how to do it in pyspark.
con_2['id'] = range(1, 1+len(con_2))
len(con_2.customer_play_id.unique())
My Pyspark code is below, but its not working
from pyspark.sql.types import IntegerType
slen = udf(lambda s: len(s), IntegerType())
con_2 = con_2.withColumn('id', F.length(con_2.customer_play_id))
expected output should be (Id is the column i want to add) df
id col1 col2
1 X Y
2 y1 y4
3 y2 y7
4 y3 y8