BaşlayınÜcretsiz Başlayın

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.

Bu egzersiz

Data Transformation with Polars

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • 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.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

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")
)
Kodu Düzenle ve Çalıştır