How to Use NumPy in Python
Categories: Tech | Pubby Cash Received:
Do you know how to use NumPy, or what NumPy even is? NumPy is basically a library for the Python programming language, adding support for large, multi-dimensional arrays and matrices, along with a large collection of high-level mathematical functions to operate on these arrays. To use NumPy, you first need to import it, like this.
import numpy as np
I will now show an example of what you can do with NumPy. First of all, you can do arrays with NumPy. Here is a example.
arr = np.array( [[ 1, 2, 3],
[ 4, 2, 5]] )
This code is basically saying that you are making a array object. After that, you can do some things like getting the size of the array. You can do it like this.
print("Size of array: ", arr.size)
The output of this would be Size of array: 6.
After reading this article, I hope you have a better understanding of NumPy and how it works.
Published from: Pennsylvania US
Liked by: H2O