My input dataframe is;
ID Amount result
45 1 default
46 2 default
47 3 default
48 5 default
48 10 default
49 12 default
50 5 default
50 7 default
50 9 default
Desired output is;
ID Amount result
45 1 default1
46 2 default1
47 3 default1
48 5 default1
48 10 default2
49 12 default1
50 5 default1
50 7 default2
50 9 default3
If ID is not changed default string should increase like this "default1", "default2". First is should always be "default1".
For python, i can do that with this code;
df['result'] += df.groupby('ID').cumcount().add(1).astype(str)
Could you please help me about for pyspark code?