NumPy என்பது Python-ல் numerical data-ஐ fast-ஆக process செய்ய பயன்படும் powerful library. NumPy full form: Nu……
NumPy
NumPy என்பது Python-ல் numerical data-ஐ fast-ஆக process செய்ய பயன்படும் powerful library. NumPy full form: Numerical Python NumPy-ன் முக்கிய purpose: Arrays, matrices, mathematical operations, statistical calculations, scientific computing…
Normal Python list: numbers = [10, 20, 30, 40] இது multiple values store செய்யும். ஆனால் large numerical data……
Install NumPy ↓ Import NumPy ↓ Create NumPy Ar……
Python list output: [10, 20, 30] Num……
Why NumPy?
NumPy use செய்வதற்கு முக்கிய காரணங்கள்: Fast numerical calculations Less code Multidimensional arrays Mat……
Very Important Difference Pyt……
List repeat ஆகிறது. NumPy:…
ஒவ்வொரு element-மும் multiply……
Installing NumPy
Command Prompt / Terminal: pip ins……
NumPy Python Standard Library-ன் built-in module அல்ல. ……
Importing NumPy
Use: numpy.array([1, 2, 3]) C……
Then: np.array([1, 2, 3])…
NumPy → np Pandas → pd Matplo……
NumPy Array
NumPy-ன் main data structure: ndarray Full form: N-dimensional Array nd……
1D array: [10 20 30] 2D array: [[……
The fundamental array object ……
One-Dimensional Array - 1D
A one-dimensional array is li……
Two-Dimensional Array - 2D
A 2D array contains rows and ……
Rows: [10 20] [30 40] Columns……
Three-Dimensional Array - 3D
Conceptually: 2 blocks ↓ Each……
Dimensions: 1D → One axis 2D ……
ndim
ndim tells number of dimensio……
ndim = Number of Dimensions…
shape
shape tells the size of each dime……
3 elements. 2D: a = np.array(……
2 rows 3 columns…
shape = Rows and Columns Stru……
size
size gives total number of el……
Because: 2 rows × 3 columns =……
dtype
dtype tells the data type of NumPy array el……
or depending on platform: int……
Exact integer dtype may vary based on pl……
N S S D N → ndim → Number of dimensions S……
Indexing in NumPy
Indexing means accessing an individua……
Array: [10 20 30 40] Indexes:……
Negative Indexing
-1 means last element.…
2D Indexing
a[row, column] Here: Row 0 Co……
2D: array[row, column]…
Slicing
Slicing means accessing a rang……
start included. stop excluded.…
Why? Start index 1 included. ……
Slice with Step
array[start:stop:step]…
Change Array Value
NumPy arrays are mutable.…
NumPy array is mutable. Exist……
Array Arithmetic
This is one of the most impor……
5 ஒவ்வொரு element-க்கும் add ……
This is called: Vectorized oper……
Array-to-Array Operations
Calculation: 10 + 1 = 11 20 +……
This is element-wise multipli……
Students may think: a * b does matrix multiplication. Not necessarily. For normal NumPy ar……
Mathematical Functions
NumPy provides many mathemati……
Aggregate Functions
Aggregate means summarizing m……
np.arange()
np.arange() creates evenly sp……
np.arange(start, stop, step)…
Stop value 6 excluded.…
np.linspace()
linspace() creates a specified nu……
np.linspace(start, stop, numb……
linspace()-ல் stop value norm……
arange → Give me the gap / st……
np.zeros()
Creates array filled with zer……
np.ones()
np.full()
Create array filled with a sp……
Identity Matrix - np.eye()
Identity matrix: Main diagona……
Reshaping Arrays
Reshaping means changing arra……
Wrong: a.reshape(4, 2) 6 elem……
Reshape condition: Original n……
Reshape: Total elements must ……
Flatten
Convert multidimensional arra……
Transpose
Rows become columns and colum……
Original: 1 2 3 4 5 6 Transpo……
Concatenation
Join arrays.…
Boolean Filtering
This is a very important NumP……
Condition: a > 25 produces conceptually: Fal……
NumPy Comparison
NumPy comparison works elemen……
Copy vs View
This is an important advanced……
Original remains unchanged.…
Because view shares underlyin……
Sorting
Searching
20 appears at indexes: 1 and 3…
Random Numbers in NumPy
Modern NumPy commonly uses ran……
5 random integers.…
Because values are random, ou……
Matrix Addition
Matrix Element-wise Multiplication
Calculation: 1×5 2×6 3×7 4×8…
Matrix Multiplication
Use: a @ b…
- → Element-wise multiplicati……
@ → Matrix multiplication Ver……
Broadcasting
Broadcasting என்பது different but compatible shapes கொண்ட arrays-க்கு N……
Here scalar 5 behaves as if a……
Think: [10 20 30] + [ 5 5 5] = [15 25 35] NumPy ……
Broadcasting allows NumPy to perfor……
Data Type Conversion
Use: astype()…
This truncates decimal parts ……
Explicit dtype
NumPy String and Mixed Values
NumPy usually tries to use a ……
Likely output: [10. 20.5] float64 Integer may be ……
NumPy arrays generally work best……
Forgetting Import Wrong: a = np.array([1, 2, 3]) w……
Writing numpy after aliasing to np If: import numpy a……
List multiplication and NumPy m……
NumPy: np.array([1, 2]) * 2…
* means Matrix Multiplication……
- → Element-wise…
@ → Matrix multiplication…
Wrong reshape a = np.array([1, 2……
Stop value in slicing a[1:4] Inde……
arange and linspace same என்று நினைப……
NumPy Master Memory A D S S I M R A → Array D → Dimension S → Shape S → Size I → Indexing M → Mathemat……
NumPy stands for: Numerical P……
Common alias: import numpy as……
Main NumPy array object: ndar……
ndim gives number of dimensio……
shape gives dimension sizes.…
size gives total number of el……
dtype gives element data type.…
NumPy indexing starts at 0.…
NumPy supports negative index……
Lists and NumPy arrays behave……
NumPy supports element-wise o……
np.arange() creates values ba……
np.linspace() creates evenly ……
np.zeros() creates zero-fille……
np.ones() creates one-filled ……
np.eye() creates identity mat……
reshape() changes array shape……
flatten() converts multidimen……
.T gives transpose.…
- performs element-wise multi……
@ performs matrix multiplicat……
Boolean indexing can filter v……
copy() creates an independent……
view() usually shares underly……
Broadcasting allows operation……
What is NumPy? Answer NumPy is a Python library for numerical and scie……
What is ndarray? Answer ndarray stands for N-dimensional ar……
Why is NumPy faster than normal Python lists for numerical operations? Answer NumPy arrays s……
What is the difference between shape and size? Answer shape desc……
What is the difference between arange() and linspace()? Answer arange() generally……
What is broadcasting? Answer Broadcasting is NumPy's mechanism……
What is the difference betwee……
- performs element-wise multi……
What is the difference between copy and view? Answer A copy……
NumPy stands for:…
Which is the common NumPy ali……
Which creates a NumPy array?…
What is the output? import nu……
Which property gives number o……
What does shape return for a ……
What does size return for a 2……
What is the output? a = np.ar……
Which function creates an arr……
Which function creates evenly……
What is the output? np.arange……
What is the output? a = np.ar……
Which operator performs eleme……
Which operator performs matri……
Which method changes the arra……
Which converts a multidimensi……
What does .T represent?…
Which is used for Boolean filtering? A. ……
Which property tells array el……
NumPy is mainly useful for:…
Create this NumPy array: 10 20 30 40 50……
Print the third element. prin……
Print the last element using ……
Create: 0 2 4 6 8 using NumPy……
Create 5 evenly spaced values……
Create a 2 × 3 zeros array. a……
Create a 3 × 3 identity matri……
Reshape: [1 2 3 4 5 6] into 2 × 3. ……
Find: a = np.array([10, 20, 3……
Filter values greater than 50: a = n……
Find mean: a = np.array([10, ……
Find maximum: print(np.max(a))…
Transpose: a = np.array([ [1,……
Explain difference between: a……
- → Element-wise multiplicati……
@ → Matrix multiplication…
Find all properties: a = np.array([ [10, 20, 30], [40, 50, 60] ]) Try: print(a.……
NumPy means Numerical Python. NumPy is used for numerical and scientific computing. Common import is import n……
- means element-wise multipli……
@ means matrix multiplication. Broadcasting allows compatible-shape operations. copy() creates independe……
NumPy → Numerical Python Alias → np Main object → ndarray Create array → np.array() Dimensions → ndim Structu……