Skip to content

REF: Rename NonFixedVariableWindowIndexer to VariableOffsetWindowIndexer #35059

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 1 commit into from
Jun 30, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions doc/source/user_guide/computation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -597,15 +597,15 @@ You can view other examples of ``BaseIndexer`` subclasses `here <https://github.

.. versionadded:: 1.1

One subclass of note within those examples is the ``NonFixedVariableWindowIndexer`` that allows
One subclass of note within those examples is the ``VariableOffsetWindowIndexer`` that allows
rolling operations over a non-fixed offset like a ``BusinessDay``.

.. ipython:: python

from pandas.api.indexers import NonFixedVariableWindowIndexer
from pandas.api.indexers import VariableOffsetWindowIndexer
df = pd.DataFrame(range(10), index=pd.date_range('2020', periods=10))
offset = pd.offsets.BDay(1)
indexer = NonFixedVariableWindowIndexer(index=df.index, offset=offset)
indexer = VariableOffsetWindowIndexer(index=df.index, offset=offset)
df
df.rolling(indexer).sum()

Expand Down
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v1.1.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ Other API changes
- ``loc`` lookups with an object-dtype :class:`Index` and an integer key will now raise ``KeyError`` instead of ``TypeError`` when key is missing (:issue:`31905`)
- Using a :func:`pandas.api.indexers.BaseIndexer` with ``count``, ``min``, ``max``, ``median``, ``skew``, ``cov``, ``corr`` will now return correct results for any monotonic :func:`pandas.api.indexers.BaseIndexer` descendant (:issue:`32865`)
- Added a :func:`pandas.api.indexers.FixedForwardWindowIndexer` class to support forward-looking windows during ``rolling`` operations.
- Added a :func:`pandas.api.indexers.NonFixedVariableWindowIndexer` class to support ``rolling`` operations with non-fixed offsets (:issue:`34994`)
- Added a :func:`pandas.api.indexers.VariableOffsetWindowIndexer` class to support ``rolling`` operations with non-fixed offsets (:issue:`34994`)
- Added :class:`pandas.errors.InvalidIndexError` (:issue:`34570`).
- :meth:`DataFrame.swaplevels` now raises a ``TypeError`` if the axis is not a :class:`MultiIndex`.
Previously an ``AttributeError`` was raised (:issue:`31126`)
Expand Down
4 changes: 2 additions & 2 deletions pandas/api/indexers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
from pandas.core.window.indexers import (
BaseIndexer,
FixedForwardWindowIndexer,
NonFixedVariableWindowIndexer,
VariableOffsetWindowIndexer,
)

__all__ = [
"check_array_indexer",
"BaseIndexer",
"FixedForwardWindowIndexer",
"NonFixedVariableWindowIndexer",
"VariableOffsetWindowIndexer",
]
2 changes: 1 addition & 1 deletion pandas/core/window/indexers.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def get_window_bounds(
)


class NonFixedVariableWindowIndexer(BaseIndexer):
class VariableOffsetWindowIndexer(BaseIndexer):
"""Calculate window boundaries based on a non-fixed offset such as a BusinessDay"""

def __init__(
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/window/test_base_indexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pandas import DataFrame, Series, date_range
import pandas._testing as tm
from pandas.api.indexers import BaseIndexer, FixedForwardWindowIndexer
from pandas.core.window.indexers import ExpandingIndexer, NonFixedVariableWindowIndexer
from pandas.core.window.indexers import ExpandingIndexer, VariableOffsetWindowIndexer

from pandas.tseries.offsets import BusinessDay

Expand Down Expand Up @@ -249,7 +249,7 @@ def test_non_fixed_variable_window_indexer(closed, expected_data):
index = date_range("2020", periods=10)
df = DataFrame(range(10), index=index)
offset = BusinessDay(1)
indexer = NonFixedVariableWindowIndexer(index=index, offset=offset)
indexer = VariableOffsetWindowIndexer(index=index, offset=offset)
result = df.rolling(indexer, closed=closed).sum()
expected = DataFrame(expected_data, index=index)
tm.assert_frame_equal(result, expected)