Go Far AI

Go Far AI

Share this post

Go Far AI
Go Far AI
The Basics of Python: Numpy
Copy link
Facebook
Email
Notes
More

The Basics of Python: Numpy

An Introduction to NumPy: The Essential Python Library for Scientific Computing

Ali Atiah Alzahrani's avatar
Ali Atiah Alzahrani
Feb 02, 2022
Share

NumPy is a Python library that is widely used for numerical and scientific computing. It provides a powerful array object and functions for working with these arrays.

Some of the most important functions in NumPy include:

  1. np.array(): creates a NumPy array from a Python list or tuple

  2. np.zeros(): creates an array filled with zeros

  3. np.ones(): creates an array filled with ones

  4. np.arange(): creates an array with a range of values

  5. np.linspace(): creates an array with a specific number of values evenly spaced between two endpoints

  6. np.random.rand(): creates an array with random values between 0 and 1

  7. np.random.randn(): creates an array with random values from a normal distribution

  8. np.min(): returns the minimum value of an array

  9. np.max(): returns the maximum value of an array

  10. np.mean(): returns the mean of an array

  11. np.std(): returns the standard deviation of an array

  12. np.sum(): returns the sum of an array

Here's an example of how to create a NumPy array and use some of these functions:

import numpy as np

# create a 1-dimensional array from a Python list
my_array = np.array([1, 2, 3, 4, 5])

# create a 2-dimensional array filled with zeros
zeros_array = np.zeros((3, 4))

# create a 1-dimensional array with values from 0 to 9
range_array = np.arange(10)

# create a 1-dimensional array with 5 values between 0 and 1
linspace_array = np.linspace(0, 1, 5)

# create a 3x3 array with random values between 0 and 1
random_array = np.random.rand(3, 3)

# compute the minimum value of an array
min_value = np.min(my_array)

# compute the mean of an array
mean_value = np.mean(random_array)

Subscribe to Go Far AI

By Ali Atiah Alzahrani
Your Guide to AI & Quant Finance
Share

Ready for more?

© 2025 Ali Atiah Alzahrani
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share

Copy link
Facebook
Email
Notes
More