CommencerCommencez gratuitement

Concatenating text columns

With the whitespace cleaned up, you realize that some products have the same detail but come in different sizes. To uniquely identify each product variant, you need to combine the detail and size columns into a single identifier.

Cet exercice fait partie du cours

<cours>Data Transformation with Polars</cours>
Voir le cours

Instructions de l’exercice

  • Concatenate the detail and size columns with a colon separator and name the new column detail_size.

Exercice interactif pratique

Essayez cet exercice en complétant ce code d’exemple.

# Combine detail and size into a new column
reviews.with_columns(
    pl.____(["detail", "size"], separator="____").____("detail_size")
)
Modifier et exécuter le code