From d7dd219cfc60bea317828d3dee29583f8e1d4faa Mon Sep 17 00:00:00 2001 From: Matthew Rocklin Date: Wed, 22 Jul 2015 08:26:08 -0700 Subject: [PATCH] to-csv works with single partition --- dask/dataframe/io.py | 2 +- dask/dataframe/tests/test_io.py | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/dask/dataframe/io.py b/dask/dataframe/io.py index 03c25ea8ae9..8267f11d926 100644 --- a/dask/dataframe/io.py +++ b/dask/dataframe/io.py @@ -614,4 +614,4 @@ def to_csv(df, filename, **kwargs): (tuple, [(df._name, i), filename]), kwargs2)) - get(merge(dsk, df.dask), (name, i), get=myget) + get(merge(dsk, df.dask), (name, df.npartitions - 1), get=myget) diff --git a/dask/dataframe/tests/test_io.py b/dask/dataframe/tests/test_io.py index 9aff6b61749..230189e074d 100644 --- a/dask/dataframe/tests/test_io.py +++ b/dask/dataframe/tests/test_io.py @@ -462,11 +462,12 @@ def test_read_hdf(): def test_to_csv(): df = pd.DataFrame({'x': ['a', 'b', 'c', 'd'], 'y': [1, 2, 3, 4]}, index=[1., 2., 3., 4.]) - a = dd.from_pandas(df, 2) - with tmpfile('csv') as fn: - a.to_csv(fn, get=get_sync) + for npartitions in [1, 2]: + a = dd.from_pandas(df, npartitions) + with tmpfile('csv') as fn: + a.to_csv(fn, get=get_sync) - result = pd.read_csv(fn, index_col=0) + result = pd.read_csv(fn, index_col=0) - tm.assert_frame_equal(result, df) + tm.assert_frame_equal(result, df)