Skip to content

Commit 9d0d1aa

Browse files
committed
Fix ibtracs call to match and groupby
1 parent 7539446 commit 9d0d1aa

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

docs/examples/IBTrACS.ipynb

+17-3
Original file line numberDiff line numberDiff line change
@@ -146,17 +146,31 @@
146146
"# Add basin data to ib_wmo\n",
147147
"ib_wmo[\"basin\"] = huracanpy.utils.get_basin(ib_wmo.lon, ib_wmo.lat)\n",
148148
"# Match tracks between ib_wmo and ib_usa, then retrieve LMI\n",
149-
"m = huracanpy.assess.match(ib_wmo, ib_usa, \"wmo\", \"usa\")\n",
149+
"m = huracanpy.assess.match([ib_wmo, ib_usa], names=[\"wmo\", \"usa\"])\n",
150150
"max_winds = m.join(\n",
151-
" ib_wmo.groupby(\"track_id\").max()[[\"wind\", \"basin\"]].to_dataframe(), on=\"id_wmo\"\n",
151+
" ib_wmo[[\"wind\"]].groupby(ib_wmo.track_id).max().to_dataframe(), on=\"id_wmo\"\n",
152152
").join(\n",
153-
" ib_usa.groupby(\"track_id\").max().wind.to_dataframe(),\n",
153+
" ib_usa[[\"wind\"]].groupby(ib_usa.track_id).max().to_dataframe(),\n",
154154
" on=\"id_usa\",\n",
155155
" lsuffix=\"_wmo\",\n",
156156
" rsuffix=\"_usa\",\n",
157157
")"
158158
]
159159
},
160+
{
161+
"cell_type": "code",
162+
"execution_count": null,
163+
"id": "bb31f486-51a4-4c49-b1ad-d67569ec9a6a",
164+
"metadata": {},
165+
"outputs": [],
166+
"source": [
167+
"# Add basin with separate groupby\n",
168+
"max_winds = max_winds.join(\n",
169+
" ib_wmo[[\"basin\"]].groupby(ib_wmo.track_id).first().to_dataframe(),\n",
170+
" on=\"id_wmo\"\n",
171+
")"
172+
]
173+
},
160174
{
161175
"cell_type": "code",
162176
"execution_count": null,

0 commit comments

Comments
 (0)