LoslegenKostenlos loslegen

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.

Diese Übung ist Teil des Kurses

Data Transformation with Polars

Kurs anzeigen

Anleitung zur Übung

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

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

# Extract skin type from reviews
reviews.with_columns(
    pl.col("review").str.____("(____|____|____)").alias("____")
)
Code bearbeiten und ausführen