Skip to content

TST: Set timeoffset as the window parameter #37407

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
Oct 26, 2020
Merged
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
61 changes: 61 additions & 0 deletions pandas/tests/window/test_rolling.py
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,67 @@ def test_rolling_var_numerical_issues(func, third_value, values):
tm.assert_series_equal(result, expected)


def test_timeoffset_as_window_parameter_for_corr():
# GH: 28266
exp = DataFrame(
{
"B": [
np.nan,
np.nan,
0.9999999999999998,
-1.0,
1.0,
-0.3273268353539892,
0.9999999999999998,
1.0,
0.9999999999999998,
1.0,
],
"A": [
np.nan,
np.nan,
-1.0,
1.0000000000000002,
-0.3273268353539892,
0.9999999999999966,
1.0,
1.0000000000000002,
1.0,
1.0000000000000002,
],
},
index=pd.MultiIndex.from_tuples(
[
(pd.Timestamp("20130101 09:00:00"), "B"),
(pd.Timestamp("20130101 09:00:00"), "A"),
(pd.Timestamp("20130102 09:00:02"), "B"),
(pd.Timestamp("20130102 09:00:02"), "A"),
(pd.Timestamp("20130103 09:00:03"), "B"),
(pd.Timestamp("20130103 09:00:03"), "A"),
(pd.Timestamp("20130105 09:00:05"), "B"),
(pd.Timestamp("20130105 09:00:05"), "A"),
(pd.Timestamp("20130106 09:00:06"), "B"),
(pd.Timestamp("20130106 09:00:06"), "A"),
]
),
)

df = DataFrame(
{"B": [0, 1, 2, 4, 3], "A": [7, 4, 6, 9, 3]},
index=[
pd.Timestamp("20130101 09:00:00"),
pd.Timestamp("20130102 09:00:02"),
pd.Timestamp("20130103 09:00:03"),
pd.Timestamp("20130105 09:00:05"),
pd.Timestamp("20130106 09:00:06"),
],
)

res = df.rolling(window="3d").corr()

tm.assert_frame_equal(exp, res)


@pytest.mark.parametrize("method", ["var", "sum", "mean", "skew", "kurt", "min", "max"])
def test_rolling_decreasing_indices(method):
"""
Expand Down