I have a DataFrame like below. I need to create a new column based on existing columns.
col1 col2
a 1
a 2
b 1
c 1
d 1
d 2
Output Data Frame look like this
col1 col2 col3 col4
a 1 1 2
a 2 1 2
b 1 0 1
c 1 0 1
d 1 1 2
d 2 1 2
The logic I have used to find col3 is if count of col1 > 1 and col4 is max value of col2.
I am familiar with how to do it in sql . But it's hard to find solution with dataframe DSL. Any help would be appreciated. Thanks