Short Product Codes

Easy
String Functions
Filtering

Short Product Codes

The products table contains product codes.

Return product_id, product_code for codes with at most 4 characters. Sort by product_id ascending.

Browser Engine: Evaluates PySpark DataFrame & SQL logic locally in Pyodide WebAssembly.

Input data

1 DataFrame

These DataFrames are passed to solve(spark, dfs). Access one with dfs['name'].

df.products6 rows
product_id (int)product_code (string)
1AB12
2LONGCODE
3X1
4P-99
512345
6Z9

Return these columns

product_id(int)
product_code(string)

Column names and order must match. Sort order is specified in the question.

Browser engine
Loading Python editor…
Click Run to try the sample cases, or Submit to check the hidden cases. First run caches the browser Python engine (~8–15s once); all code stays on your device.