Repository: dask/dask

Issue:
Update make_timeseries for pandas deprecation
```python
In [3]: dd.demo.make_timeseries()
/Users/taugspurger/sandbox/dask/dask/dataframe/io/demo.py:91: FutureWarning: Creating a DatetimeIndex by passing range endpoints is deprecated.  Use `pandas.date_range` instead.
  freq=partition_freq))
/Users/taugspurger/sandbox/dask/dask/dataframe/io/demo.py:45: FutureWarning: Creating a DatetimeIndex by passing range endpoints is deprecated.  Use `pandas.date_range` instead.
  index = pd.DatetimeIndex(start=start, end=end, freq=freq, name='timestamp')
Out[3]:
Dask DataFrame Structure:
                   id    name        x        y
npartitions=11
2000-01-31      int64  object  float64  float64
2000-02-29        ...     ...      ...      ...
...               ...     ...      ...      ...
2000-11-30        ...     ...      ...      ...
2000-12-31        ...     ...      ...      ...
Dask Name: make-timeseries, 11 tasks
```

Switching to `pd.date_range` should be fine.


Discussion:
The demo module should also be deprecated.  The main API entry point for this function is now `dask.datasets.timeseries`.  
Can I work on it?
@mrocklin i resolved the warning part. Can you guide me what you mean by deprecating the demo module. Does it need to be shifted somewhere else or do i only change the main entry point of the API in setup.py. But as i see it should be dataframes as it is named that.
Can you guide me more on this? I would be more than thankful.

Resolving patch:
diff --git a/dask/dataframe/core.py b/dask/dataframe/core.py
--- a/dask/dataframe/core.py
+++ b/dask/dataframe/core.py
@@ -4292,9 +4292,9 @@ def repartition_freq(df, freq=None):
         start = df.divisions[0].ceil(freq)
     except ValueError:
         start = df.divisions[0]
-    divisions = pd.DatetimeIndex(start=start,
-                                 end=df.divisions[-1],
-                                 freq=freq).tolist()
+    divisions = pd.date_range(start=start,
+                              end=df.divisions[-1],
+                              freq=freq).tolist()
     if not len(divisions):
         divisions = [df.divisions[0], df.divisions[-1]]
     else:
diff --git a/dask/dataframe/io/demo.py b/dask/dataframe/io/demo.py
--- a/dask/dataframe/io/demo.py
+++ b/dask/dataframe/io/demo.py
@@ -42,7 +42,7 @@ def make_categorical(n, rstate):
 
 
 def make_timeseries_part(start, end, dtypes, freq, state_data):
-    index = pd.DatetimeIndex(start=start, end=end, freq=freq, name='timestamp')
+    index = pd.date_range(start=start, end=end, freq=freq, name='timestamp')
     state = np.random.RandomState(state_data)
     columns = dict((k, make[dt](len(index), state)) for k, dt in dtypes.items())
     df = pd.DataFrame(columns, index=index, columns=sorted(columns))
@@ -87,8 +87,8 @@ def make_timeseries(start='2000-01-01',
     2000-01-01 06:00:00   960   Charlie  0.788245
     2000-01-01 08:00:00  1031     Kevin  0.466002
     """
-    divisions = list(pd.DatetimeIndex(start=start, end=end,
-                                      freq=partition_freq))
+    divisions = list(pd.date_range(start=start, end=end,
+                                   freq=partition_freq))
     state_data = random_state_data(len(divisions) - 1, seed)
     name = 'make-timeseries-' + tokenize(start, end, dtypes, freq,
                                          partition_freq, state_data)
diff --git a/dask/dataframe/utils.py b/dask/dataframe/utils.py
--- a/dask/dataframe/utils.py
+++ b/dask/dataframe/utils.py
@@ -390,8 +390,8 @@ def _nonempty_index(idx):
         return pd.DatetimeIndex(data, start=start, periods=2, freq=idx.freq,
                                 tz=idx.tz, name=idx.name)
     elif typ is pd.PeriodIndex:
-        return pd.PeriodIndex(start='1970-01-01', periods=2, freq=idx.freq,
-                              name=idx.name)
+        return pd.period_range(start='1970-01-01', periods=2, freq=idx.freq,
+                               name=idx.name)
     elif typ is pd.TimedeltaIndex:
         start = np.timedelta64(1, 'D')
         data = [start, start + 1] if idx.freq is None else None


Test patch:
diff --git a/dask/dataframe/io/tests/test_demo.py b/dask/dataframe/io/tests/test_demo.py
--- a/dask/dataframe/io/tests/test_demo.py
+++ b/dask/dataframe/io/tests/test_demo.py
@@ -18,8 +18,7 @@ def test_make_timeseries():
     assert df['C'].head().dtype == object
     assert df.index.name == 'timestamp'
     assert df.head().index.name == df.index.name
-    assert df.divisions == tuple(pd.DatetimeIndex(start='2000', end='2015',
-                                                  freq='6M'))
+    assert df.divisions == tuple(pd.date_range(start='2000', end='2015',freq='6M'))
 
     tm.assert_frame_equal(df.head(), df.head())
 
diff --git a/dask/dataframe/tests/test_dataframe.py b/dask/dataframe/tests/test_dataframe.py
--- a/dask/dataframe/tests/test_dataframe.py
+++ b/dask/dataframe/tests/test_dataframe.py
@@ -1390,7 +1390,7 @@ def test_repartition_object_index():
 def test_repartition_freq(npartitions, freq, start, end):
     start = pd.Timestamp(start)
     end = pd.Timestamp(end)
-    ind = pd.DatetimeIndex(start=start, end=end, freq='60s')
+    ind = pd.date_range(start=start, end=end, freq='60s')
     df = pd.DataFrame({'x': np.arange(len(ind))}, index=ind)
     ddf = dd.from_pandas(df, npartitions=npartitions, name='x')