Repository: pandas-dev/pandas

Issue:
BUG: date_range with negative, non-Tick frequencies returns empty DatetimeIndex
#### Code Sample, a copy-pastable example if possible

```python
In [40]: pd.__version__
Out[40]: '0.24.0.dev0+812.g5f051408f.dirty'
#Bug
In [41]: pd.date_range(start='2012-01-02', end='2011-01-02', freq='-1W')
Out[41]: DatetimeIndex([], dtype='datetime64[ns]', freq='-1W-SUN')
# Addition with a Timestamp works
In [42]: pd.Timestamp('2012-01-02') + pd.tseries.frequencies.to_offset('-1W')
Out[42]: Timestamp('2012-01-01 00:00:00')
# Tick-like frequencies work
In [43]: pd.date_range(start='2011-01-03', end='2011-01-02', freq='-12H')
Out[43]:
DatetimeIndex(['2011-01-03 00:00:00', '2011-01-02 12:00:00',
               '2011-01-02 00:00:00'],
              dtype='datetime64[ns]', freq='-12H')
```

#### Expected Output

```
In [45]: pd.date_range(end='2012-01-02', start='2011-01-02', freq='1W')[::-1]
Out[45]:
DatetimeIndex(['2012-01-01', '2011-12-25', '2011-12-18', '2011-12-11',
               '2011-12-04', '2011-11-27', '2011-11-20', '2011-11-13',
               '2011-11-06', '2011-10-30', '2011-10-23', '2011-10-16',
               '2011-10-09', '2011-10-02', '2011-09-25', '2011-09-18',
               '2011-09-11', '2011-09-04', '2011-08-28', '2011-08-21',
               '2011-08-14', '2011-08-07', '2011-07-31', '2011-07-24',
               '2011-07-17', '2011-07-10', '2011-07-03', '2011-06-26',
               '2011-06-19', '2011-06-12', '2011-06-05', '2011-05-29',
               '2011-05-22', '2011-05-15', '2011-05-08', '2011-05-01',
               '2011-04-24', '2011-04-17', '2011-04-10', '2011-04-03',
               '2011-03-27', '2011-03-20', '2011-03-13', '2011-03-06',
               '2011-02-27', '2011-02-20', '2011-02-13', '2011-02-06',
               '2011-01-30', '2011-01-23', '2011-01-16', '2011-01-09',
               '2011-01-02'],
              dtype='datetime64[ns]', freq='-1W-SUN')
```


Discussion:

Resolving patch:
diff --git a/pandas/tseries/offsets.py b/pandas/tseries/offsets.py
--- a/pandas/tseries/offsets.py
+++ b/pandas/tseries/offsets.py
@@ -2388,7 +2388,7 @@ def generate_range(start=None, end=None, periods=None,
     elif end and not offset.onOffset(end):
         end = offset.rollback(end)
 
-    if periods is None and end < start:
+    if periods is None and end < start and offset.n >= 0:
         end = None
         periods = 0
 


Test patch:
diff --git a/pandas/tests/indexes/datetimes/test_date_range.py b/pandas/tests/indexes/datetimes/test_date_range.py
--- a/pandas/tests/indexes/datetimes/test_date_range.py
+++ b/pandas/tests/indexes/datetimes/test_date_range.py
@@ -510,6 +510,16 @@ def test_timezone_comparaison_assert(self):
         with tm.assert_raises_regex(AssertionError, msg):
             date_range(start, periods=2, tz='Europe/Berlin')
 
+    def test_negative_non_tick_frequency_descending_dates(self,
+                                                          tz_aware_fixture):
+        # GH 23270
+        tz = tz_aware_fixture
+        result = pd.date_range(start='2011-06-01', end='2011-01-01',
+                               freq='-1MS', tz=tz)
+        expected = pd.date_range(end='2011-06-01', start='2011-01-01',
+                                 freq='1MS', tz=tz)[::-1]
+        tm.assert_index_equal(result, expected)
+
 
 class TestGenRangeGeneration(object):