Skip to content

Commit fa8b4dd

Browse files
committed
pandas-dev#56147 negative offset and year end interaction
1 parent 5955ca6 commit fa8b4dd

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pandas/core/arrays/datetimes.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -2773,7 +2773,12 @@ def _generate_range(
27732773
if start and not offset.is_on_offset(start):
27742774
# Incompatible types in assignment (expression has type "datetime",
27752775
# variable has type "Optional[Timestamp]")
2776-
start = offset.rollforward(start) # type: ignore[assignment]
2776+
2777+
# GH #56147 account for negative direction and range bounds
2778+
if offset.n >= 0:
2779+
start = offset.rollforward(start) # type: ignore[assignment]
2780+
else:
2781+
start = offset.rollback(start)
27772782

27782783
elif end and not offset.is_on_offset(end):
27792784
# Incompatible types in assignment (expression has type "datetime",

0 commit comments

Comments
 (0)