Skip to content

Commit b38cf8f

Browse files
authored
Advanced Indexing - Update exercise
Vary the showcase x and y coords as suggested by @ianhi
1 parent 0d9c484 commit b38cf8f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

intermediate/indexing/advanced-indexing.ipynb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -366,17 +366,19 @@
366366
"::::{admonition} Exercise\n",
367367
":class: tip\n",
368368
"\n",
369-
"In the simple 2D 5x5 Xarray data array above, select the sub-array containing (0,0),(2,2),(4,4):\n",
369+
"In the simple 2D 5x5 Xarray data array above, select the sub-array containing (0,4),(2,2),(4,0):\n",
370370
"\n",
371371
":::{admonition} Solution\n",
372372
":class: dropdown\n",
373373
"```python\n",
374374
"\n",
375-
"indices = np.array([0, 2, 4])\n",
375+
"x_indices = np.array([0, 2, 4])\n",
376+
"y_indices = np.array([4, 2, 0])\n",
376377
"\n",
377-
"index_da = xr.DataArray(indices, dims=\"points\")\n",
378+
"da_x = xr.DataArray(x_indices, dims=\"points\")\n",
379+
"da_y = xr.DataArray(y_indices, dims=\"points\")\n",
378380
"\n",
379-
"subset_da = da.sel(x=index_da, y=index_da)\n",
381+
"subset_da = da.sel(x=da_x, y=da_y)\n",
380382
"subset_da\n",
381383
"```\n",
382384
":::\n",

0 commit comments

Comments
 (0)