dict-array-dict conversion

Asked 2 years ago, Updated 2 years ago, 13 views

I want to change the array type data to dict type data.

First, the dict-type data is np.Save it as an array I have read the array type data again through np.load. However, there is an error as below to use it for the dict type.

AttributeError: 'numpy.ndarray' object has no attribute 'items'

I think it should be converted to the same form. Master, please help me.

I want to know how to transform the npload data form into the npsave data form.

python

2022-09-20 19:42

1 Answers

np.save is a function that stores numpy array.

Since dictionary is a different type from numpy array, it seems that there was a problem when saving and reloading.

Use pickle to save dictionary.


2022-09-20 19:42

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.