Skip to content

Commit e96a9a0

Browse files
committed
pandas-dev#56147 negative offset and year end interaction
1 parent 50386d8 commit e96a9a0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pandas/core/arrays/datetimes.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -2756,7 +2756,10 @@ def _generate_range(
27562756
if start and not offset.is_on_offset(start):
27572757
# Incompatible types in assignment (expression has type "datetime",
27582758
# variable has type "Optional[Timestamp]")
2759-
start = offset.rollforward(start) # type: ignore[assignment]
2759+
if offset.n >= 0:
2760+
start = offset.rollforward(start) # type: ignore[assignment]
2761+
else:
2762+
start = offset.rollback(start) # type: ignore[assignment]
27602763

27612764
# Unsupported operand types for < ("Timestamp" and "None")
27622765
if periods is None and end < start and offset.n >= 0: # type: ignore[operator]

0 commit comments

Comments
 (0)