[Numpy-discussion] AttributeError with shape command

Derek Homeier derek@astro.physik.uni-goettingen...
Mon Mar 26 19:18:46 CDT 2012


On 27.03.2012, at 2:07AM, Stephanie Cooke wrote:

> I am new to numpy. When I try to use the command array.shape, I get
> the following error:
> 
> AttributeError: 'list' object has no attribute 'shape'
> 
> Is anyone familiar with this type of error?

It means 'array' actually is not one, more precisely, not an object of type np.ndarray. 
How did you create your array? If it originates just from a list of numbers, you can 
create an array from it by 'np.array(list)' (assuming previous 'import numpy as np'). 

It's also possible that a function has returned a list of arrays where you might have 
expected a single array - so it really depends on the circumstances. 

HTH,
						Derek



More information about the NumPy-Discussion mailing list