Skip to content

API: reimplement FixedWindowIndexer.get_window_bounds to fix groupby bug #36132

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

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
69f084f
updated fixed indexer to work with rolling df and groupby
justinessert Sep 4, 2020
71830c8
updated is_weighted case
justinessert Sep 4, 2020
a449d9b
added comment
justinessert Sep 4, 2020
476fe83
corrected offset for even window sizes
justinessert Sep 5, 2020
9dfd9f3
reverted changes for weighted windows
justinessert Sep 5, 2020
f025600
reverted back to fixed func type; added func_type variable
justinessert Sep 6, 2020
5d902fd
reformatted
justinessert Sep 6, 2020
59fcd3e
merged master and resolved conflict
justinessert Sep 6, 2020
cdecf34
corrected return typing
justinessert Sep 6, 2020
4e8f844
added consistency tests
justinessert Sep 6, 2020
6e66a49
corrected typing change
justinessert Sep 6, 2020
e7fb384
reformatted test to pass blac
justinessert Sep 6, 2020
3649ca2
added typing and docstring
justinessert Sep 6, 2020
00cc1dc
fixing center param in median's _apply
justinessert Sep 6, 2020
3de7fcc
added center_min_periods test to test_grouper
justinessert Sep 7, 2020
f779321
replaced func_type with skip_offset
justinessert Sep 9, 2020
a817f87
removed unneeded class attribute
justinessert Sep 9, 2020
d72812d
moved logic into calculate_center_offset
justinessert Sep 9, 2020
96c6959
removed whitespace
justinessert Sep 9, 2020
daacae7
added whatsnew entry
justinessert Sep 12, 2020
52a8a6b
Merge remote-tracking branch 'upstream/master' into groupby-rolling
justinessert Sep 12, 2020
950018c
formatting fixes
justinessert Sep 13, 2020
0798c70
removed pytest.slow
justinessert Sep 13, 2020
f413ec8
removed typing of window
justinessert Sep 13, 2020
70679be
Merge branch 'master' into groupby-rolling
justinessert Sep 25, 2020
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
1 change: 1 addition & 0 deletions pandas/core/window/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def _apply(
floor: int = 1,
is_weighted: bool = False,
name: Optional[str] = None,
func_type: Optional[str] = None,
use_numba_cache: bool = False,
**kwargs,
):
Expand Down
20 changes: 10 additions & 10 deletions pandas/core/window/indexers.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,17 @@ def get_window_bounds(
closed: Optional[str] = None,
) -> Tuple[np.ndarray, np.ndarray]:

start_s = np.zeros(self.window_size, dtype="int64")
start_e = (
np.arange(self.window_size, num_values, dtype="int64")
- self.window_size
+ 1
)
start = np.concatenate([start_s, start_e])[:num_values]
if center:
offset = (self.window_size - 1) // 2
else:
offset = 0

end = np.arange(1 + offset, num_values + 1 + offset).astype("int64")
start = end - self.window_size

end = np.clip(end, 0, num_values)
start = np.clip(start, 0, num_values)

end_s = np.arange(self.window_size, dtype="int64") + 1
end_e = start_e + self.window_size
end = np.concatenate([end_s, end_e])[:num_values]
return start, end


Expand Down
Loading