From eca4be46e465d8e0d754f464fd11eb01d6f7f95e Mon Sep 17 00:00:00 2001 From: kushagrchitkar Date: Thu, 29 Feb 2024 20:36:47 -0500 Subject: [PATCH 1/2] Update 100-pandas-puzzles-with-solutions.ipynb --- 100-pandas-puzzles-with-solutions.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/100-pandas-puzzles-with-solutions.ipynb b/100-pandas-puzzles-with-solutions.ipynb index d2467b934..2ac2e0a00 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", From 9a5ce46bcb9a462fde470c3899c938a2c1039327 Mon Sep 17 00:00:00 2001 From: kushagrchitkar Date: Thu, 29 Feb 2024 21:06:54 -0500 Subject: [PATCH 2/2] Update 100-pandas-puzzles-with-solutions.ipynb --- 100-pandas-puzzles-with-solutions.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/100-pandas-puzzles-with-solutions.ipynb b/100-pandas-puzzles-with-solutions.ipynb index 2ac2e0a00..eebdad6f1 100644 --- a/100-pandas-puzzles-with-solutions.ipynb +++ b/100-pandas-puzzles-with-solutions.ipynb @@ -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",