Guillaume
Guillaume

Reputation: 123

How to get the true dimension of a numpy array in python?

I try to display a numpy file, then display its correct length, I put my file in folder:

import numpy as np
import os
path= "C:\\Users\\user\\Folder"
files= os.listdir(path)
filepath= os.path.join(path, files[0])
file0= np.load(filepath)
print(file0)
print (len(file0))

The result is an imbrication of tables, which gives me as length=1 instead of length=8000 :

[[ 0.01437869  0.01506449  0.01579909 ...,  0.04166172  0.0417285
   0.04172079]]

1

But I need to have is:

[ 0.01437869  0.01506449  0.01579909 ...,  0.04166172  0.0417285
   0.04172079]

8000

How to resolve this problem please.

Upvotes: 2

Views: 89

Answers (1)

Trolldejo
Trolldejo

Reputation: 466

This should work:

file0= np.load(filepath)[0]

Upvotes: 3

Related Questions