python - Serialize numpy arrays into an npz string? -
i'm looking way generate compressed binary string out of multiple numpy arrays different types. :d method recommended in question:
storing , loading numpy arrays files
is use following:
np.savez_compressed('file_name_here.npz', arr_a = a, arr_b = b)
but caveat need actual string directly , don't have path save to. there simple way directly generate binary string without saving disk? there kind of work around this?
you save compressed array stringio
object , read back,
from cstringio import stringio import numpy np x = np.ones(10) f = stringio() np.savez_compressed(f, x=x) f.seek(0) out = f.read() print(out)
Comments
Post a Comment