What features of numpy in Python are better than lists?
Editor to share with you what the function of numpy in Python is better than the list, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
1. Compared with the list, numpy has more natural and convenient integration of mathematical operations.
For example, suppose you have a list of numbers and you want to add each element to the list.
In a regular python, you would do this
A = [6, 2, 1, 4, 3] b = [e + 1 for e in a]
With numpy, you only need to do:
Import numpy as np
A = np.array ([6,2,1,4,3]) b = a + 1
2. Numpy also applies to every numpy mathematical function: for example, you can use the index of each element in the list.
Further, we can easily add array elements of the same size using numpy. For example, if we have two tables an and b of the same size, we get an and b of the sum of the different elements of the list
A = [6, 2, 1, 4, 3] b = [1, 2, 3, 2, 3] c = [E1 + e2 for (E1, e2) in zip (a, b)] the above is all the contents of the article "what is the function of numpy in Python is better than the list". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!