Skip to content

Commit

Permalink
to-csv works with single partition
Browse files Browse the repository at this point in the history
  • Loading branch information
mrocklin committed Jul 22, 2015
1 parent f34977d commit d7dd219
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dask/dataframe/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
11 changes: 6 additions & 5 deletions dask/dataframe/tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit d7dd219

Please sign in to comment.