+ 2
What the difference between Python lists and NumPy arrays?
I guess the difference is numpy functions that you can apply to np.array. But I'm not sure. Please help!
4 ответов
+ 3
Numpy elements have to be the same type;
Due fact that Numpy is written in.C, there are significant difference in code execusion. Numpy arrays are simply much faster than typical Python lists when you operate on them
+ 2
One important difference, all elements in a numpy array must be of the same type. In a list you can do this: l = [1, "car", 1.34]
In numpy array you can't.
+ 2
As far as my knowledge goes, numpy arrays are homogeneous array in memory like vectors in C++. This makes look up very fast and cpu-cache friendly.
+ 1
Numpy has some handy ways to filter or operate the array.
nparray * 5 #Multiplies each element in the array by 5.
nparray[nparray!=0] #Filters each element, that is not equal to 0.
But those can all be done with the map and filter functions on lists.