The ma.frombuffer()
function in Python is interprets a buffer as a one dimensional (1-D
) array.
ma.frombuffer(buffer, dtype=float, count=- 1, offset=0, *, like=None) = <numpy.ma.core._convert2ma object>
The ma.frombuffer()
function takes the following parameter values:
buffer
: This represents an object which exposes the buffer interface. This is required.dtype
: This represents the data type of the output or the returned array. This is optional.count
: This represents the number of items to be read from the buffer. A value of -1
indicates all the items are present in the buffer. This is optional.offset
: This represents the offset from which we start reading the buffer. This is optional.like
: This represents a reference object to allow the creation of arrays that are not NumPy
arrays.The ma.frombuffer()
function returns a 1-D
array.
import numpy as np# creating a bufferx = b'Hi how are you?'# implementing the ma.frombuffer() functionmyarray=np.frombuffer(x, dtype='S1', count=10, offset=3)print(myarray)