@@ -885,14 +885,14 @@ def test_resample_origin_epoch_with_tz_day_vs_24h(unit):
885885 random_values = np .random .default_rng (2 ).standard_normal (len (rng ))
886886 ts_1 = Series (random_values , index = rng )
887887
888- result_1 = ts_1 .resample ("D" , origin = "epoch" ).mean ()
888+ result_1 = ts_1 .resample ("D" ).mean ()
889889 result_2 = ts_1 .resample ("24h" , origin = "epoch" ).mean ()
890890 tm .assert_series_equal (result_1 , result_2 , check_freq = False )
891891 # GH#41943 check_freq=False bc Day and Hour(24) no longer compare as equal
892892
893893 # check that we have the same behavior with epoch even if we are not timezone aware
894894 ts_no_tz = ts_1 .tz_localize (None )
895- result_3 = ts_no_tz .resample ("D" , origin = "epoch" ).mean ()
895+ result_3 = ts_no_tz .resample ("D" ).mean ()
896896 result_4 = ts_no_tz .resample ("24h" , origin = "epoch" ).mean ()
897897 tm .assert_series_equal (result_1 , result_3 .tz_localize (rng .tz ), check_freq = False )
898898 tm .assert_series_equal (result_1 , result_4 .tz_localize (rng .tz ), check_freq = False )
@@ -901,7 +901,7 @@ def test_resample_origin_epoch_with_tz_day_vs_24h(unit):
901901 start , end = "2000-10-01 23:30:00+0200" , "2000-12-02 00:30:00+0200"
902902 rng = date_range (start , end , freq = "7min" ).as_unit (unit )
903903 ts_2 = Series (random_values , index = rng )
904- result_5 = ts_2 .resample ("D" , origin = "epoch" ).mean ()
904+ result_5 = ts_2 .resample ("D" ).mean ()
905905 result_6 = ts_2 .resample ("24h" , origin = "epoch" ).mean ()
906906 tm .assert_series_equal (result_1 .tz_localize (None ), result_5 .tz_localize (None ))
907907 tm .assert_series_equal (result_1 .tz_localize (None ), result_6 .tz_localize (None ))
@@ -910,6 +910,7 @@ def test_resample_origin_epoch_with_tz_day_vs_24h(unit):
910910def test_resample_origin_with_day_freq_on_dst (unit ):
911911 # GH 31809
912912 tz = "America/Chicago"
913+ msg = "The '(origin|offset)' keyword does not take effect"
913914
914915 def _create_series (values , timestamps , freq = "D" ):
915916 return Series (
@@ -927,7 +928,9 @@ def _create_series(values, timestamps, freq="D"):
927928
928929 expected = _create_series ([24.0 , 25.0 ], ["2013-11-02" , "2013-11-03" ])
929930 for origin in ["epoch" , "start" , "start_day" , start , None ]:
930- result = ts .resample ("D" , origin = origin ).sum ()
931+ warn = RuntimeWarning if origin != "start_day" else None
932+ with tm .assert_produces_warning (warn , match = msg ):
933+ result = ts .resample ("D" , origin = origin ).sum ()
931934 tm .assert_series_equal (result , expected )
932935
933936 # test complex behavior of origin/offset in a DST context
@@ -939,7 +942,8 @@ def _create_series(values, timestamps, freq="D"):
939942 # GH#61985 changed this to behave like "B" rather than "24h"
940943 expected_ts = ["2013-11-03 00:00-05:00" ]
941944 expected = _create_series ([25.0 ], expected_ts )
942- result = ts .resample ("D" , origin = "start" , offset = "-2h" ).sum ()
945+ with tm .assert_produces_warning (RuntimeWarning , match = msg ):
946+ result = ts .resample ("D" , origin = "start" , offset = "-2h" ).sum ()
943947 tm .assert_series_equal (result , expected )
944948
945949 expected_ts = ["2013-11-02 22:00-05:00" , "2013-11-03 21:00-06:00" ]
@@ -950,17 +954,20 @@ def _create_series(values, timestamps, freq="D"):
950954 # GH#61985 changed this to behave like "B" rather than "24h"
951955 expected_ts = ["2013-11-03 00:00-05:00" ]
952956 expected = _create_series ([25.0 ], expected_ts )
953- result = ts .resample ("D" , origin = "start" , offset = "2h" ).sum ()
957+ with tm .assert_produces_warning (RuntimeWarning , match = msg ):
958+ result = ts .resample ("D" , origin = "start" , offset = "2h" ).sum ()
954959 tm .assert_series_equal (result , expected )
955960
956961 expected_ts = ["2013-11-03 00:00-05:00" ]
957962 expected = _create_series ([25.0 ], expected_ts )
958- result = ts .resample ("D" , origin = "start" , offset = "-1h" ).sum ()
963+ with tm .assert_produces_warning (RuntimeWarning , match = msg ):
964+ result = ts .resample ("D" , origin = "start" , offset = "-1h" ).sum ()
959965 tm .assert_series_equal (result , expected )
960966
961967 expected_ts = ["2013-11-03 00:00-05:00" ]
962968 expected = _create_series ([25.0 ], expected_ts )
963- result = ts .resample ("D" , origin = "start" , offset = "1h" ).sum ()
969+ with tm .assert_produces_warning (RuntimeWarning , match = msg ):
970+ result = ts .resample ("D" , origin = "start" , offset = "1h" ).sum ()
964971 tm .assert_series_equal (result , expected )
965972
966973
@@ -2022,9 +2029,8 @@ def test_resample_empty_series_with_tz():
20222029 df = DataFrame ({"ts" : [], "values" : []}).astype (
20232030 {"ts" : "datetime64[ns, Atlantic/Faroe]" }
20242031 )
2025- result = df .resample ("2MS" , on = "ts" , closed = "left" , label = "left" , origin = "start" )[
2026- "values"
2027- ].sum ()
2032+ rs = df .resample ("2MS" , on = "ts" , closed = "left" , label = "left" )
2033+ result = rs ["values" ].sum ()
20282034
20292035 expected_idx = DatetimeIndex (
20302036 [], freq = "2MS" , name = "ts" , dtype = "datetime64[ns, Atlantic/Faroe]"
0 commit comments