Merge pull request #794 from sasakar/fix/deprecated-pandas-matplotlib-api

[Lesson 4] Fix deprecated matplotlib and pandas API usage in notebook
copilot/update-notebook-for-learners
Lee Stott 2 months ago committed by GitHub
commit 9f161b6d53
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -136,7 +136,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"plt.figure(figsize=(10,2))\n", "plt.figure(figsize=(10,2))\n",
"plt.boxplot(df['Height'].ffill(), vert=False, showmeans=True)\n", "plt.boxplot(df['Height'].ffill(), orientation='horizontal', showmeans=True)\n",
"plt.grid(color='gray', linestyle='dotted')\n", "plt.grid(color='gray', linestyle='dotted')\n",
"plt.tight_layout()\n", "plt.tight_layout()\n",
"plt.show()" "plt.show()"
@ -272,7 +272,7 @@
" return m, h\n", " return m, h\n",
"\n", "\n",
"for p in [0.85, 0.9, 0.95]:\n", "for p in [0.85, 0.9, 0.95]:\n",
" m, h = mean_confidence_interval(df['Weight'].fillna(method='pad'),p)\n", " m, h = mean_confidence_interval(df['Weight'].ffill(),p)\n",
" print(f\"p={p:.2f}, mean = {m:.2f} ± {h:.2f}\")" " print(f\"p={p:.2f}, mean = {m:.2f} ± {h:.2f}\")"
] ]
}, },
@ -384,7 +384,7 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"heights = df['Height'].fillna(method='pad')\n", "heights = df['Height'].ffill()\n",
"salaries = 1000+(heights-heights.min())/(heights.max()-heights.mean())*100\n", "salaries = 1000+(heights-heights.min())/(heights.max()-heights.mean())*100\n",
"print(list(zip(heights, salaries))[:10])" "print(list(zip(heights, salaries))[:10])"
] ]
@ -507,7 +507,7 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"np.corrcoef(df['Height'].fillna(method='pad'), df['Weight'])" "np.corrcoef(df['Height'].ffill(), df['Weight'])"
] ]
}, },
{ {

Loading…
Cancel
Save