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

Function test_concat_dataframe_empty

dask/dataframe/tests/test_multi.py:639–661  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

637
638
639def test_concat_dataframe_empty():
640 df = pd.DataFrame({"a": [100, 200, 300]}, dtype="int64")
641 empty_df = pd.DataFrame([], dtype="int64")
642 df_concat = pd.concat([df, empty_df])
643
644 ddf = dd.from_pandas(df, npartitions=1)
645 empty_ddf = dd.from_pandas(empty_df, npartitions=1)
646 ddf_concat = dd.concat([ddf, empty_ddf])
647 assert_eq(df_concat, ddf_concat)
648
649 empty_df_with_col = pd.DataFrame([], columns=["x"], dtype="int64")
650 df_concat_with_col = pd.concat([df, empty_df_with_col])
651 empty_ddf_with_col = dd.from_pandas(empty_df_with_col, npartitions=1)
652 ddf_concat_with_col = dd.concat([ddf, empty_ddf_with_col])
653 # NOTE: empty_ddf_with_col.index.dtype == dtype('O') while ddf.index.dtype == dtype('int64')
654 # when we concatenate the resulting ddf_concat_with_col.index.dtype == dtype('O'). However,
655 # the pandas version is smart enough to identify the empty rows and assign dtype('int64'),
656 # which causes assert_eq to fail when checking dtype. Hence the following line.
657 ddf_concat_with_col._meta.index = ddf_concat_with_col._meta.index.astype("int64")
658
659 assert_eq(df_concat_with_col, ddf_concat_with_col, check_dtype=False)
660
661 assert_eq(dd.concat([ddf, ddf[[]]]), pd.concat([df, df[[]]]))
662
663
664@pytest.mark.parametrize("how", ["inner", "outer", "left", "right"])

Callers

nothing calls this directly

Calls 2

assert_eqFunction · 0.90
astypeMethod · 0.45

Tested by

no test coverage detected