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.
本练习是课程的一部分
Data Transformation with Polars
练习说明
- Extract
"oily","dry", or"sensitive"from the"review"column as a new column called"skin_type".
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Extract skin type from reviews
reviews.with_columns(
pl.col("review").str.____("(____|____|____)").alias("____")
)