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

Matching to the nearest price update

Listing prices change over time, but inquiries arrive at irregular intervals. To analyze pricing accuracy, you want to match each inquiry to the closest price update for that listing - whether it happened before or after the inquiry.

polars is loaded as pl, and the DataFrames inquiries and price_history are available for you, both with name and date columns.

Bu egzersiz

Data Transformation with Polars

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

Egzersiz talimatları

  • Sort both DataFrames by date before joining.
  • Use the by parameter to match within each listing using the name column.
  • Set the strategy to find the closest date in either direction.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Sort and join on date
matches = inquiries.sort("____").____(
    price_history.sort("____"),
    on="date",
    # Match within each listing
    by="____",
    # Find the closest date
    strategy="____"
)

print(matches)
Kodu Düzenle ve Çalıştır