Skip to main content
Questions Why Us Pricing Log In Sign Up

df.rolling(): Datetime

How does df.rolling() work with datetime indexes?

Answer

When a DataFrame has a DatetimeIndex, the df.rolling() function can use time-based windows instead of integer sizes.

A time-based window is defined with strings such as "24H", "7D", "30min", "1H" etc.

Python
rolling_24h = df["temperature"].rolling("24h", min_periods=6, step = 24)
← Back to collection
← Previous question df.rolling() Next question What is scikit-learn? →

Social

  • Instagram

Contact

  • linkedin.com/in/rinorbirinxhiku/

Legal

  • Privacy Policy
  • Terms of Service
© 2026 quant.rb. All rights reserved.