एक से अधिक कॉलम पर rolling aggregations
मान लीजिए कि आपको एक साथ कई कॉलम पर rolling statistics चाहिए. .rolling() मेथड आपको समय-आधारित window पर कई कॉलम के लिए एक साथ aggregations निकालने देता है.
polars pl नाम से लोड है. DataFrame bikes उपलब्ध है, जिसमें time, rentals, और temp कॉलम हैं.
यह अभ्यास पाठ्यक्रम का हिस्सा है
Polars के साथ Data Transformation
अभ्यास निर्देश
timeकॉलम पर 3-hour का rolling window सेट करें.- aggregation में
rentalsका sum औरtempका mean निकालें.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# Set up the 3-hour rolling window
bikes.rolling(index_column="____", period="____").agg(
# Calculate sum of rentals and mean of temp
pl.col("rentals").____().alias("rolling_total"),
pl.col("temp").____().alias("rolling_mean_temp")
)