numpy.packbits()

numpy.packbits

numpy.packbits(myarray, axis=None)

Packs the elements of a binary-valued array into bits in a uint8 array.

The result is padded to full bytes by inserting zero bits at the end.

Parameters:

myarray : array_like

An array of integers or booleans whose elements should be packed to bits.

axis : int, optional

The dimension over which bit-packing is done. None implies packing the flattened array.

Returns:

packed : ndarray

Array of type uint8 whose ele