🧮 Introduction to NumPy
Last Updated: 02 Nov 2025
- NumPy (Numerical Python) is a powerful Python library used for numerical and scientific computing. It provides multi-dimensional arrays and fast mathematical operations on them.
- Python lists are like normal boxes, then NumPy arrays are like super-fast containers that handle big data easily (used in Data Science, ML, AI, etc.).
- It is fast because it uses C and C++ under the hood.
🗣 Hinglish Tip: “Python list har element ko alag handle karta hai, par NumPy ek hi type ke saare data ko ek saath handle karta hai — isliye fast hota hai!”
Install NumPy
Before using, install it in your system.
pip install numpy
Import numpy in your script
import numpy as np
NumPy Data Types
NumPy supports numerical data types like integers, floats, complex numbers, and booleans.
| Symbol | Meaning | Example | Description |
|---|---|---|---|
b | Boolean | bool_ | True or False |
i | Signed integer | i1, i2, i4, i8 | e.g. i4 = 4 bytes = int32 |
u | Unsigned integer | u1, u2, u4, u8 | Only positive values |
f | Floating point | f2, f4, f8 | e.g. f8 = float64 |
c | Complex floating point | c8, c16 | Complex numbers |
m | Time delta | m8[ns] | Difference between dates |
M | Datetime | M8[D], M8[ns] | Date/time data |
U,str_ | Unicode string | U21 | String (21 characters wide) |
S | Byte string | S10 | String (10 bytes) |
O | Object | object | Python objects or mixed types |