I have a process where I need to convert a numpy recarray to bytes, and after that reconstruct the recarray from the bytes.
However, I am not sure how to do recover the array from bytes.
Does anyone know how could I do it?
Example code:
import numpy as np
import pandas as pd
df = pd.DataFrame(np.zeros(500))
rec = df.to_records()
rec_s = rec.tostring() # this returns a bytes object
# perform some computation
new_rec = <method to recover from bytes>(rec_s)
Note: I don't actually need to use numpy recarry, just some structure that will allow me to transform the pandas dataframe into a bytes object, and also recover it.