@@ -884,14 +884,14 @@ def test_resample_origin_epoch_with_tz_day_vs_24h(unit):
884884 random_values = np .random .default_rng (2 ).standard_normal (len (rng ))
885885 ts_1 = Series (random_values , index = rng )
886886
887- result_1 = ts_1 .resample ("D" , origin = "epoch" ).mean ()
887+ result_1 = ts_1 .resample ("D" ).mean ()
888888 result_2 = ts_1 .resample ("24h" , origin = "epoch" ).mean ()
889889 tm .assert_series_equal (result_1 , result_2 , check_freq = False )
890890 # GH#41943 check_freq=False bc Day and Hour(24) no longer compare as equal
891891
892892 # check that we have the same behavior with epoch even if we are not timezone aware
893893 ts_no_tz = ts_1 .tz_localize (None )
894- result_3 = ts_no_tz .resample ("D" , origin = "epoch" ).mean ()
894+ result_3 = ts_no_tz .resample ("D" ).mean ()
895895 result_4 = ts_no_tz .resample ("24h" , origin = "epoch" ).mean ()
896896 tm .assert_series_equal (result_1 , result_3 .tz_localize (rng .tz ), check_freq = False )
897897 tm .assert_series_equal (result_1 , result_4 .tz_localize (rng .tz ), check_freq = False )
@@ -900,7 +900,7 @@ def test_resample_origin_epoch_with_tz_day_vs_24h(unit):
900900 start , end = "2000-10-01 23:30:00+0200" , "2000-12-02 00:30:00+0200"
901901 rng = date_range (start , end , freq = "7min" ).as_unit (unit )
902902 ts_2 = Series (random_values , index = rng )
903- result_5 = ts_2 .resample ("D" , origin = "epoch" ).mean ()
903+ result_5 = ts_2 .resample ("D" ).mean ()
904904 result_6 = ts_2 .resample ("24h" , origin = "epoch" ).mean ()
905905 tm .assert_series_equal (result_1 .tz_localize (None ), result_5 .tz_localize (None ))
906906 tm .assert_series_equal (result_1 .tz_localize (None ), result_6 .tz_localize (None ))
@@ -909,6 +909,7 @@ def test_resample_origin_epoch_with_tz_day_vs_24h(unit):
909909def test_resample_origin_with_day_freq_on_dst (unit ):
910910 # GH 31809
911911 tz = "America/Chicago"
912+ msg = "The '(origin|offset)' keyword does not take effect"
912913
913914 def _create_series (values , timestamps , freq = "D" ):
914915 return Series (
@@ -926,7 +927,9 @@ def _create_series(values, timestamps, freq="D"):
926927
927928 expected = _create_series ([24.0 , 25.0 ], ["2013-11-02" , "2013-11-03" ])
928929 for origin in ["epoch" , "start" , "start_day" , start , None ]:
929- result = ts .resample ("D" , origin = origin ).sum ()
930+ warn = RuntimeWarning if origin != "start_day" else None
931+ with tm .assert_produces_warning (warn , match = msg ):
932+ result = ts .resample ("D" , origin = origin ).sum ()
930933 tm .assert_series_equal (result , expected )
931934
932935 # test complex behavior of origin/offset in a DST context
@@ -938,7 +941,8 @@ def _create_series(values, timestamps, freq="D"):
938941 # GH#61985 changed this to behave like "B" rather than "24h"
939942 expected_ts = ["2013-11-03 00:00-05:00" ]
940943 expected = _create_series ([25.0 ], expected_ts )
941- result = ts .resample ("D" , origin = "start" , offset = "-2h" ).sum ()
944+ with tm .assert_produces_warning (RuntimeWarning , match = msg ):
945+ result = ts .resample ("D" , origin = "start" , offset = "-2h" ).sum ()
942946 tm .assert_series_equal (result , expected )
943947
944948 expected_ts = ["2013-11-02 22:00-05:00" , "2013-11-03 21:00-06:00" ]
@@ -949,17 +953,20 @@ def _create_series(values, timestamps, freq="D"):
949953 # GH#61985 changed this to behave like "B" rather than "24h"
950954 expected_ts = ["2013-11-03 00:00-05:00" ]
951955 expected = _create_series ([25.0 ], expected_ts )
952- result = ts .resample ("D" , origin = "start" , offset = "2h" ).sum ()
956+ with tm .assert_produces_warning (RuntimeWarning , match = msg ):
957+ result = ts .resample ("D" , origin = "start" , offset = "2h" ).sum ()
953958 tm .assert_series_equal (result , expected )
954959
955960 expected_ts = ["2013-11-03 00:00-05:00" ]
956961 expected = _create_series ([25.0 ], expected_ts )
957- result = ts .resample ("D" , origin = "start" , offset = "-1h" ).sum ()
962+ with tm .assert_produces_warning (RuntimeWarning , match = msg ):
963+ result = ts .resample ("D" , origin = "start" , offset = "-1h" ).sum ()
958964 tm .assert_series_equal (result , expected )
959965
960966 expected_ts = ["2013-11-03 00:00-05:00" ]
961967 expected = _create_series ([25.0 ], expected_ts )
962- result = ts .resample ("D" , origin = "start" , offset = "1h" ).sum ()
968+ with tm .assert_produces_warning (RuntimeWarning , match = msg ):
969+ result = ts .resample ("D" , origin = "start" , offset = "1h" ).sum ()
963970 tm .assert_series_equal (result , expected )
964971
965972
@@ -2021,9 +2028,8 @@ def test_resample_empty_series_with_tz():
20212028 df = DataFrame ({"ts" : [], "values" : []}).astype (
20222029 {"ts" : "datetime64[ns, Atlantic/Faroe]" }
20232030 )
2024- result = df .resample ("2MS" , on = "ts" , closed = "left" , label = "left" , origin = "start" )[
2025- "values"
2026- ].sum ()
2031+ rs = df .resample ("2MS" , on = "ts" , closed = "left" , label = "left" )
2032+ result = rs ["values" ].sum ()
20272033
20282034 expected_idx = DatetimeIndex (
20292035 [], freq = "2MS" , name = "ts" , dtype = "datetime64[ns, Atlantic/Faroe]"
0 commit comments