Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I view data object contents within an npz file?

I am using Spyder IDE and Python 2.7.

I have a npz file called data.npz which was given to me. I want to load this file into Spyder and view whatever is inside.

To start I've done this:

import numpy as np
data = np.load('data.npz')

In my Variable Explorer in Spyder, I have a variable with the name "data" and the type "object". When I double-click on this variable, Spyder gives an error saying "object arrays are currently not supported".

When I just type

data

I get something like this:

array({'a': array([ 1,2,3, ...,
         4,5,6]), 'b': 10, 'c': array([-1,-2,-3]), 'd': 25, 'e': 1}, dtype=object)

How do I access 'a', 'b', 'c', 'd', etc?

like image 878
Darcy Avatar asked May 31 '17 15:05

Darcy


1 Answers

to obtain a list of all the constituent files, simply use:

$ data.files
like image 174
Sankalp Pawar Avatar answered Oct 31 '22 19:10

Sankalp Pawar