@@ -846,6 +846,34 @@ def test_resample_origin_with_tz():
846846 ts .resample ("5min" , origin = "12/31/1999 23:57:00+03:00" ).mean ()
847847
848848
849+ def test_resample_origin_epoch_with_tz_day_vs_24h ():
850+ # GH 34474
851+ start , end = "2000-10-01 23:30:00+0500" , "2000-12-02 00:30:00+0500"
852+ rng = pd .date_range (start , end , freq = "7min" )
853+ random_values = np .random .randn (len (rng ))
854+ ts_1 = pd .Series (random_values , index = rng )
855+
856+ result_1 = ts_1 .resample ("D" , origin = "epoch" ).mean ()
857+ result_2 = ts_1 .resample ("24H" , origin = "epoch" ).mean ()
858+ tm .assert_series_equal (result_1 , result_2 )
859+
860+ # check that we have the same behavior with epoch even if we are not timezone aware
861+ ts_no_tz = ts_1 .tz_localize (None )
862+ result_3 = ts_no_tz .resample ("D" , origin = "epoch" ).mean ()
863+ result_4 = ts_no_tz .resample ("24H" , origin = "epoch" ).mean ()
864+ tm .assert_series_equal (result_1 , result_3 .tz_localize (rng .tz ), check_freq = False )
865+ tm .assert_series_equal (result_1 , result_4 .tz_localize (rng .tz ), check_freq = False )
866+
867+ # check that we have the similar results with two different timezones (+2H and +5H)
868+ start , end = "2000-10-01 23:30:00+0200" , "2000-12-02 00:30:00+0200"
869+ rng = pd .date_range (start , end , freq = "7min" )
870+ ts_2 = pd .Series (random_values , index = rng )
871+ result_5 = ts_2 .resample ("D" , origin = "epoch" ).mean ()
872+ result_6 = ts_2 .resample ("24H" , origin = "epoch" ).mean ()
873+ tm .assert_series_equal (result_1 .tz_localize (None ), result_5 .tz_localize (None ))
874+ tm .assert_series_equal (result_1 .tz_localize (None ), result_6 .tz_localize (None ))
875+
876+
849877def test_resample_origin_with_day_freq_on_dst ():
850878 # GH 31809
851879 tz = "America/Chicago"
0 commit comments