NumPy Tutorial for Data Science

Data Science 280 views Nov 14, 2025 1 min read

Introduction

NumPy (Numerical Python) is the foundation of scientific computing in Python. It provides multi-dimensional arrays and high-performance functions to operate on them.

1. Installing NumPy


pip install numpy
  

2. Creating NumPy Arrays


import numpy as np

arr = np.array([1, 2, 3, 4])
print(arr)
  

3. Multi-Dimensional Array


matrix = np.array([[1, 2], [3, 4]])
  

4. Array Properties

  • Shape
  • Size
  • Datatype

print(arr.shape)
print(arr.dtype)
  

5. Array Operations


a = np.array([1, 2, 3])
b = np.array([4, 5, 6])

print(a + b)
print(a * b)
print(a.mean())
  

6. Indexing and Slicing


arr = np.array([10, 20, 30, 40])
print(arr[1])       # 20
print(arr[1:3])     # [20, 30]
  

7. Reshaping Arrays


arr = np.arange(6)
arr = arr.reshape(2, 3)
print(arr)
  

8. Mathematical Functions


np.sqrt(arr)
np.sum(arr)
np.std(arr)
  

Conclusion

NumPy is essential for efficient numerical computation and forms the backbone of most data science libraries.

Some advanced sections are available for Registered Members
Share this Post
🚀 Want to Test Your Knowledge?

Take quizzes related to this topic and see where you stand!

Start Quiz Now
Back to Tutorials