ComenzarEmpieza gratis

Categorizing customers with conditions

Now you'll learn to create conditional expressions. The market research team wants to identify satisfied customers for a follow-up survey - customers with ratings of 4 or higher should be flagged.

The reviews DataFrame is available with 5 rows printed to preview.

Este ejercicio forma parte del curso

Data Transformation with Polars

Ver curso

Instrucciones del ejercicio

  • Check if the "rating" column is greater than or equal to 4.
  • Return "Yes" when the condition is True.
  • Return "No" when the condition is False.

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

reviews.with_columns(
  	# Check if rating is 4 or higher
    pl.____(pl.col("rating") >= ____)
  
    # Return "Yes" when True
    .____(pl.____("Yes"))
  
    # Return "No" when False
    .____(pl.____("No"))
    .alias("is_satisfied")
)
Editar y ejecutar código