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

Function test_map_partitions_df_input

dask/tests/test_distributed.py:777–816  ·  view source on GitHub ↗

Check that map_partitions can handle a delayed partition of a dataframe input

()

Source from the content-addressed store, hash-verified

775
776
777def test_map_partitions_df_input():
778 """
779 Check that map_partitions can handle a delayed
780 partition of a dataframe input
781 """
782 pd = pytest.importorskip("pandas")
783 dd = pytest.importorskip("dask.dataframe")
784
785 def f(d, a):
786 assert isinstance(d, pd.DataFrame)
787 assert isinstance(a, pd.DataFrame)
788 return d
789
790 def main():
791 item_df = dd.from_pandas(pd.DataFrame({"a": range(10)}), npartitions=1)
792 ddf = item_df.to_delayed()[0].persist()
793 merged_df = dd.from_pandas(pd.DataFrame({"b": range(10)}), npartitions=1)
794
795 # Notice, we include a shuffle in order to trigger a complex culling
796 merged_df = merged_df.shuffle(on="b", shuffle_method="tasks")
797
798 merged_df.map_partitions(
799 f, ddf, meta=merged_df, enforce_metadata=False
800 ).compute()
801
802 with distributed.LocalCluster(
803 scheduler_port=0,
804 # Explicitly disabling dashboard to prevent related warnings being
805 # elevated to errors until `bokeh=3` is fully supported.
806 # See https://github.com/dask/dask/issues/9686 and
807 # https://github.com/dask/distributed/issues/7173 for details.
808 dashboard_address=":0",
809 scheduler_kwargs={"dashboard": False},
810 asynchronous=False,
811 n_workers=1,
812 nthreads=1,
813 processes=False,
814 ) as cluster:
815 with distributed.Client(cluster, asynchronous=False):
816 main()
817
818
819@pytest.mark.filterwarnings(

Callers

nothing calls this directly

Calls 1

mainFunction · 0.70

Tested by

no test coverage detected