Record arrays allow you to access fields as elements of an array using
arr.a and arr.b
numpy.recarray.tobytes () strong > Python bytes, containing the raw data bytes in an array.
numpy.recarray.tobytes (order = `C`)p>
order: [`C`, `F`, None, optional] Order of the data for multidimensional arrays: C , Fortran, or the same as for the original array.
Return: [bytes] Python bytes exhibiting a copy of record array`s raw data.
Code # 1:
I nput array: [[(5., 2) (3., -4) (6., 9)]
[(9., 1) (5., 4) (-12., -7) ]]
Record array of float: [[5. 3. 6.]
[9. 5. -12.]]
Record array of int: [[2 -4 9]
[1 4 -7]]
Output Python bytes of float record array in default order b`x00x00x00x00x00x00x14 @ x00x00x00x00x00x00x08 @ x00x00x00x00x00x00x18 @ x00x00x00x00x00x00 ″ @ x00x00x00x00 python bytes of float record array in fortan order b`x00x00x00x00x00x00x14 @ x00x00x00x00x00x00 "@ x00x00x00x00x00x00x08 @ x00x00x00x00x00x00x14 @ x00x00x00x00x00x00x18 @ x00x00x00x00x00x00 (xc0 ` p>
Output python bytes of int record array in default order b`x02x00x00x00xfcxffxffxff x00x00x00x01x00x00x00x04x00x00x00xf9xffxffxff` p>
Output Python bytes of int record array in fortan order b`x02x00x00x00x01x00x00x00xfcxffxffxffx04x00x00x00 x00x00x00xf9xffxffxff `
Code # 2: Weapply
numpy.recarray.tobytes ()to the entire array of records. < / p>
Input array: [[(5. , 2) (3., 4) (6., -7)]
[(9., 1) (6., 4) (-2., -7)]]
Output Python bytes of record array in default order b`x00x00x00x00x00x00x14 @ x02x00x00x00x00x00x00x00x00x00x08 @ x04x00x00x00x00x00x00x00x00x00x18 @ xf9xffxffxffx00x00x00x00x00x00 ″ x00x00x00x18 @ x04x00x00x00x00x00x00x00x00x00x00xc0xf9xffxffxff ` p>
Output Python bytes of record array in fortan order b`x00x00x00x00x00x00x14 @ x02x00x00x00x00x00x00x00x00x00 "@ x01x00x00x00x00x00x00x00x00x00x08 @ x04x00x00x00x00x00x00x00x00x00x18 @ x04x00x00x00x00x00x00x00x00x00x18 @ xf9xffxffxffx00x00x00x00x00x00x00xc0xf9xffxffxff` p> blockquote>
Python: - The Bible - 3 Manuscripts in 1 book:
IRMA is a research-based professional organization dedicated to advancing the concepts and practices of information resource management in modern organizations. The primary purpose of IRMA is to promo...
Become a master in Python by learning coding best practices and advanced programming concepts in Python 3.7. This book is written for Python developers who wish to go further in mastering Python. A...
Python Crash Course is the world's best-selling guide to the Python programming language. This quick and in-depth introduction to Python programming will get you started writing programs, solving prob...