[docs]@fugue_plugindefas_fugue_dataset(data:AnyDataset,**kwargs:Any)->Dataset:"""Wrap the input as a :class:`~.Dataset` :param data: the dataset to be wrapped """ifisinstance(data,Dataset)andlen(kwargs)==0:returndataraiseNotImplementedError(f"no registered dataset conversion for {type(data)}")
[docs]defshow(data:AnyDataset,n:int=10,with_count:bool=False,title:Optional[str]=None)->None:"""Display the Dataset :param data: the dataset that can be recognized by Fugue :param n: number of rows to print, defaults to 10 :param with_count: whether to show dataset count, defaults to False :param title: title of the dataset, defaults to None .. note:: When ``with_count`` is True, it can trigger expensive calculation for a distributed dataframe. So if you call this function directly, you may need to :func:`fugue.execution.execution_engine.ExecutionEngine.persist` the dataset. """returnas_fugue_dataset(data).show(n=n,with_count=with_count,title=title)
[docs]@fugue_plugindefas_local(data:AnyDataset)->AnyDataset:"""Convert the dataset to a local dataset :param data: the dataset that can be recognized by Fugue """returnas_local_bounded(data)
[docs]@fugue_plugindefas_local_bounded(data:AnyDataset)->AnyDataset:"""Convert the dataset to a local bounded dataset :param data: the dataset that can be recognized by Fugue """raiseNotImplementedError(f"no registered function to convert {type(data)} to a local bounded dataset")
[docs]@fugue_plugindefis_local(data:AnyDataset)->bool:"""Whether the dataset is local :param data: the dataset that can be recognized by Fugue """returnas_fugue_dataset(data).is_local
[docs]@fugue_plugindefis_bounded(data:AnyDataset)->bool:"""Whether the dataset is local :param data: the dataset that can be recognized by Fugue """returnas_fugue_dataset(data).is_bounded
[docs]@fugue_plugindefis_empty(data:AnyDataset)->bool:"""Whether the dataset is empty :param data: the dataset that can be recognized by Fugue """returnas_fugue_dataset(data).empty
[docs]@fugue_plugindefcount(data:AnyDataset)->int:"""The number of elements in the dataset :param data: the dataset that can be recognized by Fugue """returnas_fugue_dataset(data).count()
[docs]@fugue_plugindefget_num_partitions(data:AnyDataset)->bool:"""Get the number of partitions of the dataset :param data: the dataset that can be recognized by Fugue """returnas_fugue_dataset(data).num_partitions