Skip to content

Commit 155c810

Browse files
committed
typo fix + remove a redundant example.
1 parent df745a5 commit 155c810

File tree

1 file changed

+20
-31
lines changed

1 file changed

+20
-31
lines changed

intermediate/indexing/advanced-indexing.ipynb

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"source": [
1818
"## Overview\n",
1919
"\n",
20-
"In the previous notebooks, we learned basic forms of indexing with xarray (positional and name based dimensions, integer and label based indexing), Datetime Indexing, and nearest neighbor lookups. In this tutorial, we will lean how Xarray indexing is different from Numpy and how to do vectorized/pointwise indexing using Xarray. \n",
20+
"In the previous notebooks, we learned basic forms of indexing with xarray (positional and name based dimensions, integer and label based indexing), Datetime Indexing, and nearest neighbor lookups. In this tutorial, we will learn how Xarray indexing is different from Numpy and how to do vectorized/pointwise indexing using Xarray. \n",
2121
"First, let's import packages needed for this repository: "
2222
]
2323
},
@@ -107,6 +107,18 @@
107107
"da.sel(lat=target_lat, lon=target_lon, method=\"nearest\") # -- orthogonal indexing"
108108
]
109109
},
110+
{
111+
"cell_type": "code",
112+
"execution_count": null,
113+
"metadata": {},
114+
"outputs": [],
115+
"source": [
116+
"target_lat = xr.DataArray([31, 41, 42, 42], dims=\"degrees_north\")\n",
117+
"target_lon = xr.DataArray([200, 201, 202, 205], dims=\"degrees_east\")\n",
118+
"\n",
119+
"da.sel(lat=target_lat, lon=target_lon, method=\"nearest\") # -- orthogonal indexing"
120+
]
121+
},
110122
{
111123
"cell_type": "markdown",
112124
"metadata": {},
@@ -229,35 +241,6 @@
229241
"```"
230242
]
231243
},
232-
{
233-
"cell_type": "markdown",
234-
"metadata": {},
235-
"source": [
236-
"Analogously, label-based pointwise-indexing is also possible by the `.sel()` method:"
237-
]
238-
},
239-
{
240-
"cell_type": "code",
241-
"execution_count": null,
242-
"metadata": {
243-
"tags": []
244-
},
245-
"outputs": [],
246-
"source": [
247-
"da = xr.DataArray(\n",
248-
" np.random.rand(4, 3),\n",
249-
" [\n",
250-
" (\"time\", pd.date_range(\"2000-01-01\", periods=4)),\n",
251-
" (\"space\", [\"IA\", \"IL\", \"IN\"]),\n",
252-
" ],\n",
253-
")\n",
254-
"times = xr.DataArray(pd.to_datetime([\"2000-01-03\", \"2000-01-02\", \"2000-01-01\"]), dims=\"new_time\")\n",
255-
"\n",
256-
"\n",
257-
"# -- get data for each state and each time:\n",
258-
"da.sel(space=xr.DataArray([\"IA\", \"IL\", \"IN\"], dims=[\"new_time\"]), time=times)"
259-
]
260-
},
261244
{
262245
"cell_type": "markdown",
263246
"metadata": {},
@@ -269,6 +252,11 @@
269252
}
270253
],
271254
"metadata": {
255+
"kernelspec": {
256+
"display_name": "Python 3 (ipykernel)",
257+
"language": "python",
258+
"name": "python3"
259+
},
272260
"language_info": {
273261
"codemirror_mode": {
274262
"name": "ipython",
@@ -278,7 +266,8 @@
278266
"mimetype": "text/x-python",
279267
"name": "python",
280268
"nbconvert_exporter": "python",
281-
"pygments_lexer": "ipython3"
269+
"pygments_lexer": "ipython3",
270+
"version": "3.11.4"
282271
},
283272
"toc": {
284273
"base_numbering": 1,

0 commit comments

Comments
 (0)