From bba744b1ce06684918a3b692b87596e9ce5e754f Mon Sep 17 00:00:00 2001 From: "James A. Bednar" Date: Mon, 1 Jun 2020 23:49:16 -0500 Subject: [PATCH] Fixed exercise 3 callbacks --- examples/tutorial/exercises/Plotting.ipynb | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/examples/tutorial/exercises/Plotting.ipynb b/examples/tutorial/exercises/Plotting.ipynb index 59ccaad1..cf41a57d 100644 --- a/examples/tutorial/exercises/Plotting.ipynb +++ b/examples/tutorial/exercises/Plotting.ipynb @@ -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", @@ -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", @@ -270,13 +271,13 @@ "
Solution
\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", @@ -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",