@@ -26,84 +26,99 @@ NumPy is a foundational Python library used for efficient numerical operations.
2626
2727---
2828
29- ## 🧩 Indexing
29+ ## 🧹 Indexing
3030
3131### 1D Array
3232``` python
3333arr[index]
34- 2D Array
35- python
36- Copy
37- Edit
34+ ```
35+
36+ ### 2D Array
37+ ``` python
3838arr[row, column]
39- 🔹 Example:
39+ ```
4040
41- python
42- Copy
43- Edit
41+ 🔹 Example:
42+ ``` python
4443arr_1d[2 ] # returns 3rd element
4544arr_2d[1 , 2 ] # returns element at 2nd row, 3rd column
46- ✂️ Slicing
47- Syntax
48- python
49- Copy
50- Edit
51- arr[start:stop:step]
52- start: starting index
45+ ```
5346
54- stop: stopping index (excluded)
47+ ---
5548
56- step: step size or skip
49+ ## ✂️ Slicing
5750
58- 🔹 Examples:
51+ ### Syntax
52+ ``` python
53+ arr[start:stop:step]
54+ ```
5955
60- python
61- Copy
62- Edit
56+ - ` start ` : starting index
57+ - ` stop ` : stopping index (excluded)
58+ - ` step ` : step size or skip
59+
60+ 🔹 Examples:
61+ ``` python
6362arr[1 :4 ] # elements from index 1 to 3
6463arr[::2 ] # every 2nd element
6564arr[::- 1 ] # reverse array
66- 🧮 2D Array Slicing
65+ ```
66+
67+ ---
68+
69+ ## �� 2D Array Slicing
70+
6771You can slice rows and columns simultaneously:
6872
69- python
70- Copy
71- Edit
73+ ``` python
7274arr[row_start:row_end, col_start:col_end]
73- 🔹 Example:
75+ ```
7476
75- python
76- Copy
77- Edit
77+ 🔹 Example:
78+ ``` python
7879arr_2d[0 :3 , 1 :3 ] # selects specific rows and columns from a 2D array
79- 🎯 Fancy Indexing
80- Fancy indexing lets you access multiple arbitrary indices at once.
80+ ```
81+
82+ ---
8183
82- 🔹 Example:
84+ ## 🎯 Fancy Indexing
8385
84- python
85- Copy
86- Edit
86+ Fancy indexing lets you access multiple arbitrary indices at once.
87+
88+ 🔹 Example:
89+ ``` python
8790arr[[0 , 2 , 4 ]] # retrieves values at those indices
88- 🧪 Boolean Masking
89- Use logical conditions to filter arrays.
91+ ```
9092
91- 🔹 Example:
93+ ---
9294
93- python
94- Copy
95- Edit
95+ ## 🧪 Boolean Masking
96+
97+ Use logical conditions to filter arrays.
98+
99+ 🔹 Example:
100+ ``` python
96101arr[arr > 25 ] # returns all values greater than 25
97- ✅ Conclusion
98- This guide covered the core techniques for working with subsets of NumPy arrays:
102+ ```
99103
100- Indexing individual elements
104+ ---
101105
102- Slicing ranges
106+ ## ✅ Conclusion
103107
104- Fancy indexing for custom selection
108+ This guide covered the core techniques for working with subsets of NumPy arrays:
105109
106- Boolean masks for condition- based filtering
110+ - Indexing individual elements
111+ - Slicing ranges
112+ - Fancy indexing for custom selection
113+ - Boolean masks for condition-based filtering
107114
108115These skills are essential for data preprocessing and manipulation in any scientific or machine learning pipeline.
109116
117+ ---
118+
119+ ## 💡 Pro Tip
120+
121+ Practice modifying arrays and chaining these techniques to prepare for real-world data workflows.
122+
123+ ---
124+
0 commit comments