Topics in this subject

16 topics

NumPy

0 of 16 complete 0%
01 2 min read

1. Introduction & Why NumPy

NumPy (Numerical Python) is the foundation of the entire Python scientific stack. Pandas, scikit-learn, TensorFlow, SciPy, and Matplotlib all sit on t

02 3 min read

2. Creating Arrays

The functions below are the workhorses for constructing arrays. Master these; they appear constantly.

03 1 min read

3. Array Attributes

Every attribute below is a cheap header read — no computation over the data.

04 1 min read

4. Data Types (dtypes)

NumPy dtypes control memory and precision.

05 2 min read

5. Indexing & Slicing

a = np.arange(10) # [0 1 2 3 4 5 6 7 8 9]

06 1 min read

6. Reshaping

a = np.arange(12)

07 2 min read

7. Broadcasting

Broadcasting lets NumPy operate on arrays of different shapes without copying data, by virtually stretching smaller arrays.

08 1 min read

8. Mathematical Operations

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

09 2 min read

9. Aggregations

axis=0 collapses rows (result has one value per column). axis=1 collapses columns (one value per row).

10 1 min read

10. Sorting & Searching

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

11 1 min read

11. Combining & Splitting Arrays

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

12 1 min read

12. Linear Algebra

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

13 1 min read

13. Random Module

Modern NumPy uses the Generator API (np.random.defaultrng), which is preferred over legacy np.random..

14 1 min read

14. Performance Optimization

result = np.empty(len(a))

15 4 min read

15. NumPy Interview Questions (40+)

1. Why is NumPy faster than Python lists?

16 1 min read

NumPy Exercises

N1. Create a 3×3 array of numbers 1–9.