API¶
The local bolt array implements the core API, as well as the additional methods listed here (for conversions). Full method documentation can be found below (methods directly inherited from numpy’s ndarray not shown).
toarray() | Returns the underlying ndarray wrapped by this BoltArrayLocal |
tordd(sc[, axis]) | Converts a BoltArrayLocal into an RDD |
tospark(sc[, axis]) | Converts a BoltArrayLocal into a BoltArraySpark |
toscalar() | Returns the single scalar element contained in an array of shape (), if the array has that shape. |
Detailed API¶
- class bolt.local.array.BoltArrayLocal[source]¶
-
- filter(func, axis=(0, ))[source]¶
Filter array along an axis.
Applies a function which should evaluate to boolean, along a single axis or multiple axes. Array will be aligned so that the desired set of axes are in the keys, which may require a transpose/reshape.
Parameters: func : function
Function to apply, should return boolean
axis : tuple or int, optional, default=(0,)
Axis or multiple axes to filter along.
Returns: BoltArrayLocal
- map(func, axis=(0, ))[source]¶
Apply a function across an axis.
Array will be aligned so that the desired set of axes are in the keys, which may require a transpose/reshape.
Parameters: func : function
Function of a single array to apply
axis : tuple or int, optional, default=(0,)
Axis or multiple axes to apply function along.
Returns: BoltArrayLocal
- reduce(func, axis=0)[source]¶
Reduce an array along an axis.
Applies an associative/commutative function of two arguments cumulatively to all arrays along an axis. Array will be aligned so that the desired set of axes are in the keys, which may require a transpose/reshape.
Parameters: func : function
Function of two arrays that returns a single array
axis : tuple or int, optional, default=(0,)
Axis or multiple axes to reduce along.
Returns: BoltArrayLocal
- tordd(sc, axis=0)[source]¶
Converts a BoltArrayLocal into an RDD
Parameters: sc : SparkContext
The SparkContext which will be used to create the BoltArraySpark
axis : tuple or int, optional, default=0
The axis (or axes) across which this array will be parallelized
Returns: RDD[(tuple, ndarray)]