@@ -885,14 +885,14 @@ def test_resample_origin_epoch_with_tz_day_vs_24h(unit):
885
885
random_values = np .random .default_rng (2 ).standard_normal (len (rng ))
886
886
ts_1 = Series (random_values , index = rng )
887
887
888
- result_1 = ts_1 .resample ("D" , origin = "epoch" ).mean ()
888
+ result_1 = ts_1 .resample ("D" ).mean ()
889
889
result_2 = ts_1 .resample ("24h" , origin = "epoch" ).mean ()
890
890
tm .assert_series_equal (result_1 , result_2 , check_freq = False )
891
891
# GH#41943 check_freq=False bc Day and Hour(24) no longer compare as equal
892
892
893
893
# check that we have the same behavior with epoch even if we are not timezone aware
894
894
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 ()
896
896
result_4 = ts_no_tz .resample ("24h" , origin = "epoch" ).mean ()
897
897
tm .assert_series_equal (result_1 , result_3 .tz_localize (rng .tz ), check_freq = False )
898
898
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):
901
901
start , end = "2000-10-01 23:30:00+0200" , "2000-12-02 00:30:00+0200"
902
902
rng = date_range (start , end , freq = "7min" ).as_unit (unit )
903
903
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 ()
905
905
result_6 = ts_2 .resample ("24h" , origin = "epoch" ).mean ()
906
906
tm .assert_series_equal (result_1 .tz_localize (None ), result_5 .tz_localize (None ))
907
907
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):
910
910
def test_resample_origin_with_day_freq_on_dst (unit ):
911
911
# GH 31809
912
912
tz = "America/Chicago"
913
+ msg = "The '(origin|offset)' keyword does not take effect"
913
914
914
915
def _create_series (values , timestamps , freq = "D" ):
915
916
return Series (
@@ -927,7 +928,9 @@ def _create_series(values, timestamps, freq="D"):
927
928
928
929
expected = _create_series ([24.0 , 25.0 ], ["2013-11-02" , "2013-11-03" ])
929
930
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 ()
931
934
tm .assert_series_equal (result , expected )
932
935
933
936
# test complex behavior of origin/offset in a DST context
@@ -939,7 +942,8 @@ def _create_series(values, timestamps, freq="D"):
939
942
# GH#61985 changed this to behave like "B" rather than "24h"
940
943
expected_ts = ["2013-11-03 00:00-05:00" ]
941
944
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 ()
943
947
tm .assert_series_equal (result , expected )
944
948
945
949
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"):
950
954
# GH#61985 changed this to behave like "B" rather than "24h"
951
955
expected_ts = ["2013-11-03 00:00-05:00" ]
952
956
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 ()
954
959
tm .assert_series_equal (result , expected )
955
960
956
961
expected_ts = ["2013-11-03 00:00-05:00" ]
957
962
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 ()
959
965
tm .assert_series_equal (result , expected )
960
966
961
967
expected_ts = ["2013-11-03 00:00-05:00" ]
962
968
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 ()
964
971
tm .assert_series_equal (result , expected )
965
972
966
973
@@ -2022,9 +2029,8 @@ def test_resample_empty_series_with_tz():
2022
2029
df = DataFrame ({"ts" : [], "values" : []}).astype (
2023
2030
{"ts" : "datetime64[ns, Atlantic/Faroe]" }
2024
2031
)
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 ()
2028
2034
2029
2035
expected_idx = DatetimeIndex (
2030
2036
[], freq = "2MS" , name = "ts" , dtype = "datetime64[ns, Atlantic/Faroe]"
0 commit comments