CommencerCommencez gratuitement

Removing whitespace

With the ratings now stored as integers, you notice another issue in the dataset: some values in the detail column have leading whitespace. This inconsistency could cause problems when grouping products by their detail type - " eau de toilette" and "eau de toilette" would be treated as different categories.

Cet exercice fait partie du cours

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

Instructions de l’exercice

  • Remove leading whitespace from the detail column by calling the .strip_chars_start() method.

Exercice interactif pratique

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

# Remove leading whitespace from the detail column
reviews.____(
    pl.col("detail").____.____()
)
Modifier et exécuter le code