BUG:remove rollback from generate_range
State: closed

'elif end and not offset.onOffset(end): end = offset.rollback(end)' gives
unwanted results for e.g. offset=MonthEnd when start.time() > end.time()


EXAMPLE:
In [1]: import pandas as pd

In [2]: from datetime import datetime

In [3]: pd.date_range(freq='M', start=datetime(2019, 4, 30, 0, 2), end=datetime(2019, 7, 1, 0, 1))
Out[3]: DatetimeIndex(['2019-04-30 00:02:00', '2019-05-31 00:02:00'], dtype='datetime64[ns]', freq='M')

In [4]: pd.date_range(freq='M', start=datetime(2019, 4, 30, 0, 1), end=datetime(2019, 7, 1, 0, 1))
Out[4]: DatetimeIndex(['2019-04-30 00:01:00', '2019-05-31 00:01:00', '2019-06-30 00:01:00'],
              dtype='datetime64[ns]', freq='M')

line 3 output expected to include 2019-06-30 as only 1 minute difference between start dates in lines 3 and 4




- [ ] closes #xxxx
- [x] tests added / passed
- [ ] passes `black pandas`
- [ ] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry


Labels:
name: Frequency
description: DateOffsets

Comments:
can you add a unit test
is there an open issue for this?
> is there an open issue for this?

Not that we could find.
> pls also add a whatsnew note in bug fixes datetimelike

Done.
> can you add a unit test

Done.
> Can you also add test for the reverse case and with the `tz_aware_fixture` to test timezones?
> 
> ` pd.date_range(freq='-M', end=datetime(2019, 4, 30, 0, 2), start=datetime(2019, 7, 1, 0, 1))`

exploring the negative offset case, we've noticed that e.g. pd.date_range(freq=pd.offsets.MonthEnd(-1), start=datetime(2019, 10, 1), end=datetime(2019, 9, 29))
returns
DatetimeIndex(['2019-10-31', '2019-09-30'], dtype='datetime64[ns]', freq='-1M')
which is unexpected as 2019-10-31 is well out of the range of start and end

we suspect that this is caused by the behaviour of offset.rollforward/offset.rollback, we feel that rollback with a negative offset should be equivalent to rollforward with a positive offset

would you be happy with us changing the behaviour of rollback/rollforward to reflect this?
Hello @Alpima-Quant! Thanks for updating this PR. We checked the lines you've touched for [PEP 8](https://www.python.org/dev/peps/pep-0008) issues, and found:



* In the file [`pandas/tseries/offsets.py`](https://github.com/pandas-dev/pandas/blob/43750b3878423e30a5db8db1289997364cd7c0ae/pandas/tseries/offsets.py):

> [Line 395:72](https://github.com/pandas-dev/pandas/blob/43750b3878423e30a5db8db1289997364cd7c0ae/pandas/tseries/offsets.py#L395): [W291](https://duckduckgo.com/?q=pep8%20W291) trailing whitespace
> [Line 400:1](https://github.com/pandas-dev/pandas/blob/43750b3878423e30a5db8db1289997364cd7c0ae/pandas/tseries/offsets.py#L400): [W293](https://duckduckgo.com/?q=pep8%20W293) blank line contains whitespace
> [Line 404:63](https://github.com/pandas-dev/pandas/blob/43750b3878423e30a5db8db1289997364cd7c0ae/pandas/tseries/offsets.py#L404): [W291](https://duckduckgo.com/?q=pep8%20W291) trailing whitespace


Agreed that the current behavior of `pd.date_range(freq=pd.offsets.MonthEnd(-1), start=datetime(2019, 10, 1), end=datetime(2019, 9, 29))` doesn't look right. Happy to have the behavior fixed as well. 
can you merge master and update to comments
@Alpima-Quant can you merge master and update to any open comments.
Nice PR but I think this has gone stale and CI is all red. Closing for now but if you'd like to pick back up and get tests to pass please ping