-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
Center rolling window for time offset #38780
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
Changes from 55 commits
Commits
Show all changes
61 commits
Select commit
Hold shift + click to select a range
11c1bb7
update syntax for pandas style
adamamiller 3cac891
Merge branch 'master' of https://github.com/pandas-dev/pandas into ce…
adamamiller c73ffc4
fix syntax error
adamamiller 58a8ebf
Merge branch 'master' of github.com:pandas-dev/pandas into center_window
luholacc dca9d04
reintroduce calculate_center_offset as private function
luholacc 37cb6fa
fix double declaration of index_growth_sign
luholacc 81e0e4e
apply review suggestions
luholacc 463c7f0
remove unneccessary exception
luholacc 321f07c
add method "_center_window" to class BaseWindow
luholacc 9270bab
use spaces around operators
luholacc dd33e32
remove unneccessary calculations from rolling.py, tests work again
luholacc 6e4da84
remove "test_invalid_center_datetimelike"
luholacc e0966e8
remove white spaces and TODO
luholacc b82f514
remove unnecessary lines
luholacc 18a7b5b
Merge branch 'master' of github.com:pandas-dev/pandas into center_window
luholacc 9c4cc58
change existing test to cover new case
luholacc c27f50e
adapt test parameters
luholacc abaa43b
add center testing to test_closed_fixed
sevberg dc046da
clean test_closed_fixed_binary_col
sevberg 95e3f26
fix formatting and rename `center_window` to `center`
luholacc 8d582a1
define len of test data dynamically
luholacc 8d5a55c
move if-statement back into two lines (failed before)
luholacc 525cc69
remove hard-coded center
sevberg 6ac79b9
remove fixture
sevberg 9bf6ce3
use `center` fixture for `test_closed_fixed_binary_col`
luholacc 4f98fc5
add `center` testing to `test_rolling_window_as_string`
luholacc e5ae3b2
correct expected data and remove debug prints
luholacc d106940
align ddof usage of rolling sem with nanops nansem
sevberg d4f6d22
explicitly test centered datetimelike windows
sevberg c2a7333
correct sem test
sevberg 73313e6
align rolling.sem with nanops.nansem
sevberg 92f8992
fix test
sevberg 648d2d3
revert ddof behavior
sevberg 278d33f
revert sem test
sevberg 5e50f36
side-step ddof bug
sevberg c11cf15
fix black failure
sevberg 2e3f875
disable black
sevberg f63309b
fix missing datetimelike word
sevberg 9f76a41
update whatsnew
sevberg f05ed61
add to enhancements
sevberg 6fbd080
Merge remote-tracking branch 'upstream/master' into center_window
sevberg dff6942
Merge branch 'master' of https://github.com/pandas-dev/pandas into ce…
Zaubeerer 0520e18
trim trailing whitespaces
luholacc a087a6b
Merge branch 'master' of github.com:pandas-dev/pandas into center_window
luholacc 5b9b8ff
correct `too many blank lines`
luholacc fca3b4d
fix wrong var name after merge
luholacc 6c1c58a
remove unused `type: ignore`
luholacc b7e5035
Merge branch 'master' of github.com:pandas-dev/pandas into center_window
luholacc f44c6e6
fix datatype in docstring (now bool)
luholacc 3dcad64
dd parametrize for window_selections
luholgit 0f9f6df
black formatting
luholgit 315b320
parametrize "test_rolling_window_as_string" outside of function
luholgit f7d1110
add whatsnew note
luholgit fc88ae4
remove center=False, is already default
luholgit e07a1f2
remove prompts and output from whatsnew
luholgit cefbb16
remove `in` and `out` annotations
luholgit edbfd21
add datetime-like center example
luholgit bfc0f0d
add test for different behavior of window alignment
luholgit 43e04ed
additional output in centering example
luholgit 1e724dc
additional output in centering example and comparison
luholgit 47a3b14
add version tag 1.3
luholgit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,6 +134,30 @@ a copy will no longer be made (:issue:`32960`) | |
The default behavior when not passing ``copy`` will remain unchanged, i.e. | ||
a copy will be made. | ||
|
||
Centered Datetime-Like Rolling Windows | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
When performing rolling calculations on :class:`DataFrame` and :class:`Series` | ||
objects with a datetime-like index, a centered datetime-like window can now be | ||
used (:issue:`38780`). | ||
For example: | ||
|
||
.. ipython:: python | ||
|
||
In [1]: df = DataFrame( | ||
{"A": [0, 1, 2, 3, 4]}, | ||
index=date_range("2020", periods=5, freq="1D") | ||
) | ||
|
||
In [2]: df.rolling("2D", center=True).mean() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't need the |
||
Out [2]: | ||
A | ||
2020-01-01 0.5 | ||
2020-01-02 1.5 | ||
2020-01-03 2.5 | ||
2020-01-04 3.5 | ||
2020-01-05 4.0 | ||
|
||
.. _whatsnew_130.enhancements.other: | ||
|
||
Other enhancements | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would not object to an example in window.rst as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the same example also to the window.rst now