I have a Dataframe with single column like shown below.
Type
'BAT'
'BAT'
'BALL'
'BAT'
'BALL'
'BALL'
To the above dataframe I have added a new column called 'const'.
df = df.withColumn('const',F.lit(1))
How do I perform a cumsum using window.partionBy() on 'const' column and create new row_id column?
Expected Output
Type  row_id
'BAT'   1
'BAT'   2
'BALL'  3
'BAT'   4
'BALL'  5
'BALL'  6
I also dont want to use RDD, everything should be in Dataframe due to performance reasons.
EDIT
- I want the row id to increment by +1
 - Dont want to use monotonically_increasing() function due to above reason