0

I am having the data shown in the image:

Data

I have been trying to partition and order this data frame in such a way so that we get the output as shown in the below image:

Data

Have tried partitioning and sorting with different columns such as partitioning by id and date and ordering by id, date, and column3 then again tried with partitioning and ordering by id and date but in all the cases it shows the different output.

Can anyone help with this? I am struggling for the past week on this.

1
  • can you post expected output & post code what you have tried so far ? Commented May 25, 2021 at 6:46

1 Answer 1

1

I am not sure if I understand correctly but that should work for your example:

df = df.orderBy(f.col('id').asc(),f.col('date').asc(),f.col('column3').desc())
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.