fugue.bag

fugue.bag.array_bag

class fugue.bag.array_bag.ArrayBag(data, copy=True)[source]

Bases: LocalBoundedBag

Parameters:
  • data (Any)

  • copy (bool)

as_array()[source]

Convert to a native python array

Returns:

the native python array

Return type:

List[Any]

count()[source]

Get number of rows of this dataframe

Return type:

int

property empty: bool

Whether this dataframe is empty

head(n)[source]

Take the first n elements

Returns:

the python array of the first n elements

Parameters:

n (int)

Return type:

LocalBoundedBag

property native: List[Any]

The underlying Python list object

peek()[source]

Peek the first row of the dataframe as array

Raises:

FugueDatasetEmptyError – if it is empty

Return type:

Any

fugue.bag.bag

class fugue.bag.bag.Bag[source]

Bases: Dataset

The base class of Fugue Bags. Bag contains a collection of unordered objects.

abstract as_array()[source]

Convert to a native python array

Returns:

the native python array

Return type:

List[Any]

as_local()[source]

Convert this bag to a LocalBag

Return type:

LocalBag

abstract as_local_bounded()[source]

Convert this bag to a LocalBoundedBag

Return type:

LocalBoundedBag

abstract head(n)[source]

Take the first n elements

Returns:

the python array of the first n elements

Parameters:

n (int)

Return type:

LocalBoundedBag

abstract peek()[source]

Peek the first row of the dataframe as array

Raises:

FugueDatasetEmptyError – if it is empty

Return type:

Any

class fugue.bag.bag.BagDisplay(ds)[source]

Bases: DatasetDisplay

Bag plain display class

Parameters:

ds (Dataset)

property bg: Bag

The target Bag

show(n=10, with_count=False, title=None)[source]

Show the Dataset

Parameters:
  • n (int) – top n items to display, defaults to 10

  • with_count (bool) – whether to display the total count, defaults to False

  • title (str | None) – title to display, defaults to None

Return type:

None

class fugue.bag.bag.LocalBag[source]

Bases: Bag

property is_local: bool

Whether this dataframe is a local Dataset

property num_partitions: int

Number of physical partitions of this dataframe. Please read the Partition Tutorial

class fugue.bag.bag.LocalBoundedBag[source]

Bases: LocalBag

as_local_bounded()[source]

Convert this bag to a LocalBoundedBag

Return type:

LocalBoundedBag

property is_bounded: bool

Whether this dataframe is bounded