Repository: dask/dask

Issue:
Left side of old and new divisions are different
When working on this dataset I need to repartition it for optimization reasons and get the following exception
```
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/shughes/miniconda3/lib/python3.5/site-packages/dask/dataframe/core.py", line 862, in repartition
    return repartition_npartitions(self, npartitions)
  File "/Users/shughes/miniconda3/lib/python3.5/site-packages/dask/dataframe/core.py", line 3645, in repartition_npartitions
    return df.repartition(divisions=divisions)
  File "/Users/shughes/miniconda3/lib/python3.5/site-packages/dask/dataframe/core.py", line 864, in repartition
    return repartition(self, divisions, force=force)
  File "/Users/shughes/miniconda3/lib/python3.5/site-packages/dask/dataframe/core.py", line 3703, in repartition
    df._name, tmp, out, force=force)
  File "/Users/shughes/miniconda3/lib/python3.5/site-packages/dask/dataframe/core.py", line 3499, in repartition_divisions
    raise ValueError(msg)
ValueError: left side of old and new divisions are different
```
If any light could be shed on this that would be great.  The code to reproduce is here and I have attached the parquet dataset (you will need fastparquet installed)

```
df = dd.read_parquet('whever_you_put_the_dataset')
df.repartition(npartitions=50)
```
[testparquet.zip](https://github.com/dask/dask/files/1106550/testparquet.zip)



Discussion:
This looks like a rounding error
So I suspect that this change will safely fix this error:

```diff
diff --git a/dask/dataframe/core.py b/dask/dataframe/core.py
index 5f0be93..a1bc39c 100644
--- a/dask/dataframe/core.py
+++ b/dask/dataframe/core.py
@@ -3627,6 +3627,10 @@ def repartition_npartitions(df, npartitions):
             if isinstance(divisions, np.ndarray):
                 divisions = tuple(divisions.tolist())
 
+            divisions = list(divisions)
+            divisions[0] = df.divisions[0]
+            divisions[-1] = df.divisions[-1]
+
             return df.repartition(divisions=divisions)
         else:
             ratio = npartitions / df.npartitions
```

What we could really use here is a test case to make sure that this doesn't revert in the future.  @shughes-uk I don't suppose you have a reproducible example that doesn't depend on downloading a file?
I'm not sure I understand what causes it enough to make something reproducible. Is it just the number of rows or is it something specific to time indexes?
When we ask for a minimal reproducible case we're looking for something that we can easily rerun, ideally with minimal work.  This would be something that we can put into a test case (like [this one](https://github.com/dask/dask/blob/master/dask/dataframe/tests/test_dataframe.py#L2637-L2643)) so it has to be pretty small because we want tests to be fast and we're unlikely to include files in the repository.  

I can figure something out, but in the future minimal examples that we can just drop into a test are super-well-appreciated.  This is usually 80% of the work on our end.
Oh I understand why you guys want minimal examples I just didn't know how to create one in this case because changing the dataset stopped the bug from occurring.
Ah, then you have my apologies for explaining unnecessarily.  

I'll figure out something

Resolving patch:
diff --git a/dask/dataframe/core.py b/dask/dataframe/core.py
--- a/dask/dataframe/core.py
+++ b/dask/dataframe/core.py
@@ -3640,7 +3640,11 @@ def repartition_npartitions(df, npartitions):
                 divisions = divisions.astype(original_divisions.dtype)
 
             if isinstance(divisions, np.ndarray):
-                divisions = tuple(divisions.tolist())
+                divisions = divisions.tolist()
+
+            divisions = list(divisions)
+            divisions[0] = df.divisions[0]
+            divisions[-1] = df.divisions[-1]
 
             return df.repartition(divisions=divisions)
         else:


Test patch:
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
@@ -1143,6 +1143,17 @@ def test_repartition_npartitions(use_index, n, k, dtype, transform):
     assert all(map(len, parts))
 
 
+def test_repartition_npartitions_same_limits():
+    df = pd.DataFrame({'x': [1, 2, 3]},
+                      index=[pd.Timestamp('2017-05-09 00:00:00.006000'),
+                             pd.Timestamp('2017-05-09 02:45:00.017999'),
+                             pd.Timestamp('2017-05-09 05:59:58.938999')])
+
+    ddf = dd.from_pandas(df, npartitions=2)
+
+    ddf.repartition(npartitions=10)
+
+
 def test_repartition_object_index():
     df = pd.DataFrame({'x': [1, 2, 3, 4, 5, 6] * 10},
                       index=list('abdabd') * 10)