I have four numpy arrays X_train
, y_train
, X_test
, y_test
.
I want to know how do I export and import them all together.
I tried exporting them using
numpy.save("data.npy",list, [X_train, y_train, X_test, y_test])
I then tried importing using
np_data = numpy.load("data.npy", allow_pickle=True)
But I can't access the data, and get the following errors:
np_data
says array(<class 'list'>, dtype=object)
np_data[0]
says IndexError: too many indices for array: array is 0-dimensional, but 1 were indexed
and also I don't understand why allow_pickle
is necessary ?
numpy.savez
, i.e.numpy.savez("data.npy", X_train=X_train, y_train=y_train, X_test=X_test, y_test=y_test)
? $\endgroup$numpy.savez
did the job. Didn't know about it. Thanks. $\endgroup$