What is the difference between resample() and asfreq() for changing the frequency of time series data?

Quick Overview

Asks how the pandas resample and asfreq methods differ when changing the frequency of a time series. Tests what each method does to the index and the values when downsampling and upsampling, and how the resulting gaps are filled.

What is the difference between resample() and asfreq() for changing the frequency of time series data?

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: easy

Interview Round: Other

What is the difference between `resample()` and `asfreq()` for changing the frequency of time series data? Consider both directions: moving to a coarser frequency (downsampling) and to a finer one (upsampling). ```hint Picture the grid Take a series with several readings per day and ask what each method does with the readings that do not sit exactly on midnight. ``` ### What a Strong Answer Covers - What each method does to the index, and whether it computes anything from the values - What happens when downsampling, including which observations are kept or combined - What happens when upsampling, and how the gaps get filled - When to choose each one ### Follow-up Questions - If the first timestamp is 09:30, what timestamps does `asfreq("D")` produce, and how does that differ from `resample("D")`? - How do `closed` and `label` change the output of `resample`, for example when building 5-minute bars? - How would you build daily OHLC bars from tick data and still keep the days with no trades? - How does `resample` relate to `groupby` with `pd.Grouper`?

Overview: Asks how the pandas resample and asfreq methods differ when changing the frequency of a time series. Tests what each method does to the index and the values when downsampling and upsampling, and how the resulting gaps are filled.

General logo
General
Nov 25, 2026
easyData ScientistOtherData Manipulation (SQL/Python)
0
0

What is the difference between resample() and asfreq() for changing the frequency of time series data?

Consider both directions: moving to a coarser frequency (downsampling) and to a finer one (upsampling).

What a Strong Answer Covers Guidance

  • What each method does to the index, and whether it computes anything from the values
  • What happens when downsampling, including which observations are kept or combined
  • What happens when upsampling, and how the gaps get filled
  • When to choose each one

Follow-up Questions Guidance

  • If the first timestamp is 09:30, what timestamps does asfreq("D") produce, and how does that differ from resample("D") ?
  • How do closed and label change the output of resample , for example when building 5-minute bars?
  • How would you build daily OHLC bars from tick data and still keep the days with no trades?
  • How does resample relate to groupby with pd.Grouper ?