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

Filtering with multiple conditions

Budget alone can still return unsuitable homes - a cheap studio won't work for a family needing multiple bedrooms. Tighten the match by adding a second condition: listings must also have at least as many bedrooms as the request requires.

polars is loaded as pl, and the DataFrames hotels and requests are available for you.

Bu egzersiz

Data Transformation with Polars

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

Egzersiz talimatları

  • Match hotels to requests where price is at or below max_price AND bedrooms is at or above min_bedrooms.
  • Print a few rows to verify the tighter matches.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Match on budget and bedroom requirements
matches = hotels.join_where(
    ____,
    pl.col("price") <= pl.col("____"),
    pl.col("bedrooms") >= pl.col("____")
)

# Print a few rows
print(matches.____())
Kodu Düzenle ve Çalıştır