Skip to content

Commit 8eaf04a

Browse files
gabriellm1Kevin D Smith
authored and
Kevin D Smith
committed
TST: Set timeoffset as the window parameter (pandas-dev#37407)
* test added * pep8 resolved * fixes
1 parent a1b306c commit 8eaf04a

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

pandas/tests/window/test_rolling.py

+61
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,67 @@ def test_rolling_var_numerical_issues(func, third_value, values):
919919
tm.assert_series_equal(result, expected)
920920

921921

922+
def test_timeoffset_as_window_parameter_for_corr():
923+
# GH: 28266
924+
exp = DataFrame(
925+
{
926+
"B": [
927+
np.nan,
928+
np.nan,
929+
0.9999999999999998,
930+
-1.0,
931+
1.0,
932+
-0.3273268353539892,
933+
0.9999999999999998,
934+
1.0,
935+
0.9999999999999998,
936+
1.0,
937+
],
938+
"A": [
939+
np.nan,
940+
np.nan,
941+
-1.0,
942+
1.0000000000000002,
943+
-0.3273268353539892,
944+
0.9999999999999966,
945+
1.0,
946+
1.0000000000000002,
947+
1.0,
948+
1.0000000000000002,
949+
],
950+
},
951+
index=pd.MultiIndex.from_tuples(
952+
[
953+
(pd.Timestamp("20130101 09:00:00"), "B"),
954+
(pd.Timestamp("20130101 09:00:00"), "A"),
955+
(pd.Timestamp("20130102 09:00:02"), "B"),
956+
(pd.Timestamp("20130102 09:00:02"), "A"),
957+
(pd.Timestamp("20130103 09:00:03"), "B"),
958+
(pd.Timestamp("20130103 09:00:03"), "A"),
959+
(pd.Timestamp("20130105 09:00:05"), "B"),
960+
(pd.Timestamp("20130105 09:00:05"), "A"),
961+
(pd.Timestamp("20130106 09:00:06"), "B"),
962+
(pd.Timestamp("20130106 09:00:06"), "A"),
963+
]
964+
),
965+
)
966+
967+
df = DataFrame(
968+
{"B": [0, 1, 2, 4, 3], "A": [7, 4, 6, 9, 3]},
969+
index=[
970+
pd.Timestamp("20130101 09:00:00"),
971+
pd.Timestamp("20130102 09:00:02"),
972+
pd.Timestamp("20130103 09:00:03"),
973+
pd.Timestamp("20130105 09:00:05"),
974+
pd.Timestamp("20130106 09:00:06"),
975+
],
976+
)
977+
978+
res = df.rolling(window="3d").corr()
979+
980+
tm.assert_frame_equal(exp, res)
981+
982+
922983
@pytest.mark.parametrize("method", ["var", "sum", "mean", "skew", "kurt", "min", "max"])
923984
def test_rolling_decreasing_indices(method):
924985
"""

0 commit comments

Comments
 (0)