Skip to content

Commit

Permalink
Fixed exercise 3 callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
jbednar committed Jun 2, 2020
1 parent 5a13262 commit bba744b
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions examples/tutorial/exercises/Plotting.ipynb
Expand Up @@ -36,6 +36,7 @@
"import hvplot.xarray # noqa: adds hvplot method to xarray objects\n",
"\n",
"df = dd.read_parquet('../../data/earthquakes.parq')\n",
"df.time = df.time.astype('datetime64[ns]')\n",
"cleaned_df = df.copy()\n",
"cleaned_df['mag'] = df.mag.where(df.mag > 0)\n",
"cleaned_reindexed_df = cleaned_df.set_index(cleaned_df.time)\n",
Expand Down Expand Up @@ -248,13 +249,13 @@
"metadata": {},
"outputs": [],
"source": [
"def circles_callback(indices):\n",
"def circles_callback(index):\n",
" circles = []\n",
" if len(indices) == 0:\n",
" if len(index) == 0:\n",
" return hv.Overlay([])\n",
" \n",
" for index in indices:\n",
" row = most_severe.iloc[index] # noqa\n",
" for i in index:\n",
" row = most_severe.iloc[i] # noqa\n",
" circle = ... # Define the appropriate Ellipse element here\n",
" circles.append(circle)\n",
" return hv.Overlay(circles)\n",
Expand All @@ -270,13 +271,13 @@
"<details><summary>Solution</summary><br>\n",
"\n",
"```python\n",
"def circles_callback(indices):\n",
"def circles_callback(index):\n",
" circles = []\n",
" if len(indices) == 0:\n",
" if len(index) == 0:\n",
" return hv.Overlay([])\n",
" \n",
" for index in indices:\n",
" row = most_severe.iloc[index]\n",
" for i in index:\n",
" row = most_severe.iloc[i]\n",
" circle = hv.Ellipse(row.longitude, row.latitude, 10) \n",
" circles.append(circle)\n",
" \n",
Expand Down Expand Up @@ -394,8 +395,8 @@
" circles = []\n",
" if len(index) == 0:\n",
" return hv.Overlay([])\n",
" for ind in index:\n",
" row = most_severe.iloc[ind]\n",
" for i in index:\n",
" row = most_severe.iloc[i]\n",
" circle = hv.Ellipse(row.longitude, row.latitude, 10) # Define the appropriate Ellipse element here\n",
" circles.append(circle)\n",
" \n",
Expand Down

0 comments on commit bba744b

Please sign in to comment.