Session Ready
Exercise

Windowed aggregations

data.table's j clause can be used to apply functions to data. Combining by and floor(), we can generate fixed-window aggregates such as "1-day average"!

Windowed aggregations are incredibly valuable in doing data science with time series data. They can be used to downsample high-frequency data so plotting code doesn't make your computer explode.

passengerDT from the previous exercise has been preserved in this session.

In this exercise, we're going to use the "hour_end" indicator in that dataset to generate windowed aggregations.

Instructions 1/3
undefined XP
  • 1
    • Take the mean of "passengers" within each one-hour window. Inspect the output in the console.
    • 2
      • Store the mean number of passengers by hour in a column called "mean_passengers".
    • 3
      • Generate a data.table with the hourly minimum ("min_passengers") and maximum ("max_passengers") passengers.