-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecated and remove from_legacy_dataframe usage (#1168)
Co-authored-by: James Bourbeau <[email protected]>
- Loading branch information
1 parent
a7a963a
commit ef6f27f
Showing
12 changed files
with
181 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,42 @@ | ||
from dask.dataframe.io.io import _df_to_bag | ||
from dask.tokenize import tokenize | ||
|
||
from dask_expr import FrameBase | ||
|
||
|
||
def to_bag(df, index=False, format="tuple"): | ||
from dask.dataframe.io import to_bag as _to_bag | ||
"""Create Dask Bag from a Dask DataFrame | ||
Parameters | ||
---------- | ||
index : bool, optional | ||
If True, the elements are tuples of ``(index, value)``, otherwise | ||
they're just the ``value``. Default is False. | ||
format : {"tuple", "dict", "frame"}, optional | ||
Whether to return a bag of tuples, dictionaries, or | ||
dataframe-like objects. Default is "tuple". If "frame", | ||
the original partitions of ``df`` will not be transformed | ||
in any way. | ||
Examples | ||
-------- | ||
>>> bag = df.to_bag() # doctest: +SKIP | ||
""" | ||
from dask.bag.core import Bag | ||
|
||
df = df.optimize() | ||
|
||
return _to_bag(df.to_legacy_dataframe(), index=index, format=format) | ||
if not isinstance(df, FrameBase): | ||
raise TypeError("df must be either DataFrame or Series") | ||
name = "to_bag-" + tokenize(df._name, index, format) | ||
if format == "frame": | ||
dsk = df.dask | ||
name = df._name | ||
else: | ||
dsk = { | ||
(name, i): (_df_to_bag, block, index, format) | ||
for (i, block) in enumerate(df.__dask_keys__()) | ||
} | ||
dsk.update(df.__dask_graph__()) | ||
return Bag(dsk, name, df.npartitions) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.