In reading npz When it comes to documents , appear Object arrays cannot be loaded when allow_pickle=False, stay NumPy
v1.16.3 Time , parameter allow_pickle The default value of is set to False, so NumPy stay v1.16.3 Version above , Need to set allow_pickle =
True, Can be read correctly npz file , The following is an example 《Python Data analysis and Application 》 Data files in a book as an example , Read data .
import numpy as np data = np.load('../data/ Quarterly data of national accounts .npz',allow_pickle = True)
# Loading data data.files # see npz There are several compressed files under the file npy name = data['columns'] #
Extract the columns array , Label as data values = data['values']# Extract the values array , Where does the data exist
stay Spyder Click above to view name,values, There will be object arrays are currently not
supported, current Spyder Version does not support viewing multidimensional arrays ndarray, So you can convert it to dataframe Check it out , The code is as follows :
import pandas as pd name = pd.DataFrame(name) values = pd.DataFrame(values)
Technology