Skip to content

DOC: clarify default window in rolling method #18177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 30, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion doc/source/computation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,9 @@ The following methods are available:
:meth:`~Window.sum`, Sum of values
:meth:`~Window.mean`, Mean of values

The weights used in the window are specified by the ``win_type`` keyword. The list of recognized types are:
The weights used in the window are specified by the ``win_type`` keyword.
The list of recognized types are the `scipy.signal window functions
<https://docs.scipy.org/doc/scipy/reference/signal.html#window-functions>`__:

- ``boxcar``
- ``triang``
Expand Down
3 changes: 3 additions & 0 deletions pandas/core/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,9 @@ class Window(_Window):
* ``general_gaussian`` (needs power, width)
* ``slepian`` (needs width).

If ``win_type=None`` a boxcar window is used. To learn more about different
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not correct, the default is in fact win_type=None, which means your window is specified by the the window parameters; only if you actually specify a win_type do you get a specific weighted window.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fundamentally doing a rolling window calculation involves choosing a window, so what window does passing win_type=None choose? I thought it was a boxcar?

Is it valid to specify both the window parameters and the window type, or can only one be provided?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

most operations are an u weighted window
only if you specify win_type do you get a special weighted window (which also has only sum/mean) methods (this is not very common usage, not using win_type is by far the most common)

i think the docs in computation are pretty clear in this

certainly could add more / better examples in the doc string

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, so if you don't specify win_type you get an un-weighted window, which is a boxcar window, which is what my addition says.

I disagree that the docs are pretty clear, and I think this helps clear them up. (I also think it doesn't confuse anything, and I'm 99% sure what I've written is correct!)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the current default uniform unweighted window is apparently a boxcar window (which I only learned by looking up what a boxcar window is).
I think that I am not alone in that, therefore I would change the explanation slightly to first explain what the default window is, and then only to say that this is called a boxcar window (people should certainly not need to follow a link to know what the meaning of the default is IMO)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I think I understand the confusion now - I don't have time now, but will try and revise later.

window types see `scipy.signal window functions
<https://docs.scipy.org/doc/scipy/reference/signal.html#window-functions>`__.
"""

def validate(self):
Expand Down