question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not clear which window is default for df.rolling()

See original GitHub issue

The docstring for df.rolling() doesn’t say which window is the default (I assume it’s boxcar?): https://pandas-docs.github.io/pandas-docs-travis/generated/pandas.DataFrame.rolling.html

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
dstansbycommented, Oct 16, 2017

You don’t have to explicitly specify it - according to the docs window is an optional keyword argument

import pandas as pd
import numpy as np

ser = pd.Series(np.random.randn(10), index=pd.date_range('1/1/2000', periods=10))

print(ser.rolling(window=5, win_type='boxcar').mean())
print(ser.rolling(window=5, win_type=None).mean())

Both of those print statements give the same thing, which means that win_type=None uses a boxcar window, but reading the docs I don’t think there is any way of knowing that.

0reactions
jrebackcommented, Oct 16, 2017

@dstansby it doesn’t, you must explicity specify. it if you want that ‘kind’ of window. Full documentation is: http://pandas.pydata.org/pandas-docs/stable/computation.html#rolling-windows

maybe should link to it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Left-align a pandas rolling object - python - Stack Overflow
Namely when the window shrinks at the end of the data would cause right alignment shrinking window by default. So you must reverse...
Read more >
Don't Miss Out on Rolling Window Functions in Pandas
Rolling Functions in a Pandas DataFrame ; 1. Window Rolling Mean (Moving Average) · df['Rolling Close Average'] = df['Close*'].rolling(2).mean().
Read more >
pandas.DataFrame.rolling — pandas 1.5.2 documentation
If 0 or 'index' , roll across the rows. If 1 or 'columns' , roll across the columns. For Series this parameter is...
Read more >
How rolling() Function works in Pandas Dataframe? - eduCBA
Pandas rolling() function gives the element of moving window counts. The idea of moving window figuring is most essentially utilized in signal handling...
Read more >
Pandas Series: rolling() function - w3resource
The rolling() function is used to provide rolling window calculations. Syntax: Series.rolling(self, window, min_periods=None, center=False, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found