84. Build Preference Pairs from Ratings
Difficulty: Hard · Topics: Data Prep for AI, Window Functions, Joins
An advanced problem: unlock it to open the statement, sample data and editor. Graded on 3 test cases.
Learn the concepts
- row_number / rank · 4 min read. Number and rank rows inside a window, and how the three ranking functions treat ties.
- join · 5 min read. Combine DataFrames on a key: inner, left, right and full joins, and the duplicate-key fan-out trap.
- select · 6 min read. Choose, rename and compute columns, and why select beats a chain of withColumn calls.
PySpark functions you'll practise
- Row Number
- Window spec
- join
- isNotNull
- filter
- select
- withColumn
- orderBy
Related problems
- Fit Conversations into a Context Window · Hard · Data Prep for AI, Window Functions, Joins
- Remove Near-Duplicate Documents · Medium · Data Prep for AI, Window Functions, Strings
- Filter Low-Quality Training Text · Medium · Data Prep for AI, Strings, Null Handling
- Split Train and Test With No User in Both · Medium · Data Prep for AI, Joins, Aggregations
- Mask Personal Data Before Training · Easy · Data Prep for AI, Strings, Filtering & Selection
Browse
Topics: Window Functions · Joins · Aggregations · Pivot, Unpivot & Rollup · Arrays · Null Handling · Conditional Logic · Dates · Filtering & Selection · Strings · Data Lake · Lakehouse · Streaming · Data Prep for AI · Spark Performance
Difficulty: Easy · Medium · Hard · Learn · All problems · dbt practice