MCPcopy Create free account
hub / github.com/dask/dask / test_blockwise_dataframe_io

Function test_blockwise_dataframe_io

dask/tests/test_distributed.py:531–560  ·  view source on GitHub ↗
(c, tmpdir, io, from_futures)

Source from the content-addressed store, hash-verified

529)
530@pytest.mark.parametrize("from_futures", [True, False])
531def test_blockwise_dataframe_io(c, tmpdir, io, from_futures):
532 pd = pytest.importorskip("pandas")
533 dd = pytest.importorskip("dask.dataframe")
534
535 df = pd.DataFrame({"x": [1, 2, 3] * 5, "y": range(15)})
536
537 if from_futures:
538 parts = [df.iloc[:5], df.iloc[5:10], df.iloc[10:15]]
539 futs = c.scatter(parts)
540 ddf0 = dd.from_delayed(futs, meta=parts[0])
541 else:
542 ddf0 = dd.from_pandas(df, npartitions=3)
543
544 if io == "parquet":
545 pytest.importorskip("pyarrow")
546 ddf0.to_parquet(str(tmpdir))
547 ddf = dd.read_parquet(str(tmpdir))
548 elif io == "csv":
549 ddf0.to_csv(str(tmpdir), index=False)
550 ddf = dd.read_csv(os.path.join(str(tmpdir), "*"))
551 elif io == "hdf":
552 pytest.importorskip("tables")
553 fn = str(tmpdir.join("h5"))
554 ddf0.to_hdf(fn, "/data*")
555 ddf = dd.read_hdf(fn, "/data*")
556 else:
557 raise AssertionError("unreachable")
558
559 df = df[["x"]] + 10
560 ddf = ddf[["x"]] + 10
561
562
563@gen_cluster(client=True)

Callers

nothing calls this directly

Calls 8

from_delayedMethod · 0.80
to_parquetMethod · 0.80
read_parquetMethod · 0.80
to_csvMethod · 0.80
read_csvMethod · 0.80
to_hdfMethod · 0.80
read_hdfMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected