Error while converting a list into a numpy array

0 votes

I have a list

len(list) = 9260  
list[0].shape = (224,224,3)  

Now when I try to convert it to a numpy array, 

x = np.array(list)  

I get the following error:

ValueError: could not broadcast input array from shape (224,224,3) into shape (224,224)  
Jun 13 in Python by Siara

edited Jun 13 13 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes
The only possible reason I could think of with this error is that probably one of your list element is not 3 dimensional. Have a closer look at your list, its data structure.
answered Jun 13 by Rhea
Thanks, @Rhea, that was the exact same issue with my list. The inner array, one element wasn't a 3 dimensional.

Related Questions In Python

0 votes
1 answer

How do I turn a list into numpy array?

Use this line: numpy_array = np.array(list) And printing/displaying the ...READ MORE

answered May 24 in Python by Isha
12 views
+1 vote
2 answers

View onto a numpy array?

 just index it as you normally would. ...READ MORE

answered Oct 18, 2018 in Python by roberto
36 views
0 votes
1 answer

How can I convert a list of dictionaries from a CSV into a JSON object in Python?

You could try using the AST module. ...READ MORE

answered Apr 17, 2018 in Python by anonymous
492 views
0 votes
1 answer

how can i count the items in a list?

suppose you have a list a = [0,1,2,3,4,5,6,7,8,9,10] now ...READ MORE

answered May 2 in Python by Mohammad
• 1,400 points
69 views
+4 votes
6 answers
+4 votes
7 answers

Splitting a List into chunks in Python

Here's a generator that yields the chunks ...READ MORE

answered Apr 13, 2018 in Python by Nietzsche's daemon
• 4,260 points
2,464 views
0 votes
1 answer

In Python, how do I read a file line-by-line into a list?

with open(fname) as f:     content = f.readlines() # you ...READ MORE

answered Oct 9, 2018 in Python by SDeb
• 11,080 points
80 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.