Skip to content

Commit c42e788

Browse files
hasB4KMathisF-AC
authored andcommitted
CLN: small refactor in resample.py
1 parent 2771381 commit c42e788

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

pandas/core/resample.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -1693,14 +1693,15 @@ def _get_timestamp_range_edges(
16931693
-------
16941694
A tuple of length 2, containing the adjusted pd.Timestamp objects.
16951695
"""
1696-
index_tz = first.tz
1697-
if isinstance(origin, Timestamp) and (origin.tz is None) != (index_tz is None):
1698-
raise ValueError("The origin must have the same timezone as the index.")
1699-
if origin == "epoch":
1700-
# set the epoch based on the timezone to have similar result between timezones
1701-
origin = Timestamp("1970-01-01", tz=index_tz)
1702-
17031696
if isinstance(freq, Tick):
1697+
index_tz = first.tz
1698+
if isinstance(origin, Timestamp) and (origin.tz is None) != (index_tz is None):
1699+
raise ValueError("The origin must have the same timezone as the index.")
1700+
elif origin == "epoch":
1701+
# set the epoch based on the timezone to have similar result when
1702+
# resampling the same kind of data on different timezones
1703+
origin = Timestamp("1970-01-01", tz=index_tz)
1704+
17041705
if isinstance(freq, Day):
17051706
# _adjust_dates_anchored assumes 'D' means 24H, but first/last
17061707
# might contain a DST transition (23H, 24H, or 25H).

0 commit comments

Comments
 (0)