Return the array data as a string containing the raw bytes in the array. The array is filled with a fill value before the string conversion. Parameters ---------- fill_value : scalar, optional Value used to fill in the masked values. Default is
(self, fill_value=None, order='C')
| 6365 | return result.tolist() |
| 6366 | |
| 6367 | def tobytes(self, fill_value=None, order='C'): |
| 6368 | """ |
| 6369 | Return the array data as a string containing the raw bytes in the array. |
| 6370 | |
| 6371 | The array is filled with a fill value before the string conversion. |
| 6372 | |
| 6373 | Parameters |
| 6374 | ---------- |
| 6375 | fill_value : scalar, optional |
| 6376 | Value used to fill in the masked values. Default is None, in which |
| 6377 | case `MaskedArray.fill_value` is used. |
| 6378 | order : {'C','F','A'}, optional |
| 6379 | Order of the data item in the copy. Default is 'C'. |
| 6380 | |
| 6381 | - 'C' -- C order (row major). |
| 6382 | - 'F' -- Fortran order (column major). |
| 6383 | - 'A' -- Any, current order of array. |
| 6384 | - None -- Same as 'A'. |
| 6385 | |
| 6386 | See Also |
| 6387 | -------- |
| 6388 | numpy.ndarray.tobytes |
| 6389 | tolist, tofile |
| 6390 | |
| 6391 | Notes |
| 6392 | ----- |
| 6393 | As for `ndarray.tobytes`, information about the shape, dtype, etc., |
| 6394 | but also about `fill_value`, will be lost. |
| 6395 | |
| 6396 | Examples |
| 6397 | -------- |
| 6398 | >>> import numpy as np |
| 6399 | >>> x = np.ma.array(np.array([[1, 2], [3, 4]]), mask=[[0, 1], [1, 0]]) |
| 6400 | >>> x.tobytes() |
| 6401 | b'\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00?B\\x0f\\x00\\x00\\x00\\x00\\x00?B\\x0f\\x00\\x00\\x00\\x00\\x00\\x04\\x00\\x00\\x00\\x00\\x00\\x00\\x00' |
| 6402 | |
| 6403 | """ |
| 6404 | return self.filled(fill_value).tobytes(order=order) |
| 6405 | |
| 6406 | def tofile(self, fid, sep="", format="%s"): |
| 6407 | """ |