Skip to content

Commit b9b2a04

Browse files
committed
Update numpy_basic_to_advance.ipynb
1 parent f9a4ee9 commit b9b2a04

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

Module 2 - Python for Data Analysis/02. High Speed Computations with NumPy/numpy_basic_to_advance.ipynb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3098,7 +3098,21 @@
30983098
"cell_type": "markdown",
30993099
"metadata": {},
31003100
"source": [
3101-
"### **Iterating using `np.nditer()`**"
3101+
"### **Iterating using `np.nditer()`**\n",
3102+
"\n",
3103+
"**np.nditer()** is an advanced NumPy iterator that provides efficient element-wise access to arrays.\n",
3104+
"\n",
3105+
"**Syntax**\n",
3106+
"```python\n",
3107+
"for x in np.nditer(arr, op_flags=[\"readwrite\"]):\n",
3108+
" x[...] = -1\n",
3109+
"```\n",
3110+
"\n",
3111+
"- The op_flags=['readwrite'] allows modifying array values in-place (default is 'readonly').\n",
3112+
"- x[...] is equivalent to x = -1, but it ensures modification happens in-place.\n",
3113+
"- `x` here is just a temporary variable referring to the current element.\n",
3114+
"- When we do x = -1, it simply reassigns x, but doesn't modify the original array.\n",
3115+
"- [...] ensures modifications affect the original array.\n"
31023116
]
31033117
},
31043118
{

0 commit comments

Comments
 (0)