CommencerCommencer gratuitement

Extracting strings from text

Beyond searching, you can also extract specific keywords from text. The skincare team wants to personalize product recommendations based on customers' skin types mentioned in reviews.

Cet exercice fait partie du cours

Data Transformation with Polars

Afficher le cours

Instructions

  • Extract "oily", "dry", or "sensitive" from the "review" column as a new column called "skin_type".

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# Extract skin type from reviews
reviews.with_columns(
    pl.col("review").str.____("(____|____|____)").alias("____")
)
Modifier et exécuter le code