diff --git a/100-pandas-puzzles-with-solutions.ipynb b/100-pandas-puzzles-with-solutions.ipynb index d2467b934..eebdad6f1 100644 --- a/100-pandas-puzzles-with-solutions.ipynb +++ b/100-pandas-puzzles-with-solutions.ipynb @@ -672,7 +672,7 @@ "source": [ "df = pd.DataFrame({'X': [7, 2, 0, 3, 4, 2, 5, 0, 3, 4]})\n", "\n", - "izero = np.r_[-1, (df == 0).values.nonzero()[0]] # indices of zeros\n", + "izero = np.r_[-1, (df == 0).values.to_numpy().nonzero()[0]] # indices of zeros\n", "idx = np.arange(len(df))\n", "y = df['X'] != 0\n", "df['Y'] = idx - izero[np.searchsorted(izero - 1, idx) - 1]\n", @@ -793,7 +793,7 @@ "\n", "def replace(group):\n", " mask = group<0\n", - " group[mask] = group[~mask].mean()\n", + " group[mask] = group[~mask].mean().astype('int32')\n", " return group\n", "\n", "df.groupby(['grps'])['vals'].transform(replace)\n",