We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5955ca6 commit fa8b4ddCopy full SHA for fa8b4dd
pandas/core/arrays/datetimes.py
@@ -2773,7 +2773,12 @@ def _generate_range(
2773
if start and not offset.is_on_offset(start):
2774
# Incompatible types in assignment (expression has type "datetime",
2775
# variable has type "Optional[Timestamp]")
2776
- start = offset.rollforward(start) # type: ignore[assignment]
+
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)
2782
2783
elif end and not offset.is_on_offset(end):
2784
0 commit comments