def to_bag(df, index=False):
 from ...bag.core import Bag
 if (not isinstance(df, (DataFrame, Series))):
  raise TypeError('df must be either DataFrame or Series')
 name = ('to_bag-' + tokenize(df, index))
 dsk = dict((((name, i), (_df_to_bag, block, index)) for (i, block) in enumerate(df._keys())))
 dsk.update(df._optimize(df.dask, df._keys()))
 return Bag(dsk, name, df.npartitions)

def to_bag ( df , index = False ) : from ... bag . core import Bag if ( not isinstance ( df , ( DataFrame , Series ) ) ) : raise TypeError ( 'df must be either DataFrame or Series' ) name = ( 'to_bag-' + tokenize ( df , index ) ) dsk = dict ( ( ( ( name , i ) , ( _df_to_bag , block , index ) ) for ( i , block ) in enumerate ( df . _keys ( ) ) ) ) dsk . update ( df . _optimize ( df . dask , df . _keys ( ) ) ) return Bag ( dsk , name , df . npartitions )
create dask bag from a dask dataframe parameters index : bool .