79568334

Date: 2025-04-11 08:10:13
Score: 0.5
Natty:
Report link

Can't you just .replace() the values?

df.sort(pl.col("a").replace(l, range(len(l))))
shape: (5, 2)
┌─────┬─────┐
│ a   ┆ b   │
│ --- ┆ --- │
│ i64 ┆ str │
╞═════╪═════╡
│ 1   ┆ x   │
│ 3   ┆ z   │
│ 5   ┆ f   │
│ 2   ┆ y   │
│ 4   ┆ p   │
└─────┴─────┘
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Starts with a question (0.5): Can't you
  • High reputation (-2):
Posted by: jqurious