Skip to content

Commit

Permalink
pandas-dev#56147 negative offset and year end interaction
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmylow committed Jan 11, 2024
1 parent 5955ca6 commit fa8b4dd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2773,7 +2773,12 @@ def _generate_range(
if start and not offset.is_on_offset(start):
# Incompatible types in assignment (expression has type "datetime",
# variable has type "Optional[Timestamp]")
start = offset.rollforward(start) # type: ignore[assignment]

# GH #56147 account for negative direction and range bounds
if offset.n >= 0:
start = offset.rollforward(start) # type: ignore[assignment]
else:
start = offset.rollback(start)

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

0 comments on commit fa8b4dd

Please sign in to comment.