From 8a5f2d1a979e25da3d36c59921b416e61fe7078c Mon Sep 17 00:00:00 2001 From: Eric Rizzi Date: Sun, 13 Aug 2023 09:47:17 -0500 Subject: [PATCH] Typo nits. Update cumulative lit graph b/c of loss of cumsum --- chapters/01/2/why-data-science.md | 2 +- chapters/01/3/1/Literary_Characters.ipynb | 30 +++++++++++------------ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/chapters/01/2/why-data-science.md b/chapters/01/2/why-data-science.md index bc398a0a0..e45a7c5cf 100644 --- a/chapters/01/2/why-data-science.md +++ b/chapters/01/2/why-data-science.md @@ -15,7 +15,7 @@ their work, their scientific endeavors, and their personal decisions. Critical thinking has long been a hallmark of a rigorous education, but critiques are often most effective when supported by data. A critical analysis of any aspect of the world, may it be business or social science, involves inductive -reasoning; conclusions can rarely been proven outright, but only supported by +reasoning; conclusions can rarely be proven outright, but only supported by the available evidence. Data science provides the means to make precise, reliable, and quantitative arguments about any set of observations. With unprecedented access to information and computing, critical thinking about diff --git a/chapters/01/3/1/Literary_Characters.ipynb b/chapters/01/3/1/Literary_Characters.ipynb index d9ff12420..6b78e170b 100644 --- a/chapters/01/3/1/Literary_Characters.ipynb +++ b/chapters/01/3/1/Literary_Characters.ipynb @@ -10,7 +10,7 @@ }, "outputs": [], "source": [ - "from datascience import *\n", + "from datascience import Table\n", "import numpy as np\n", "path_data = '../../../'\n", "import matplotlib\n", @@ -74,20 +74,20 @@ } ], "source": [ - "# Count how many times the names Jim, Tom, and Huck appear in each chapter.\n", + "# Get the cumulative counts the names Jim, Tom, and Huck appear in each chapter.\n", "\n", "counts = Table().with_columns([\n", - " 'Jim', np.char.count(huck_finn_chapters, 'Jim'),\n", - " 'Tom', np.char.count(huck_finn_chapters, 'Tom'),\n", - " 'Huck', np.char.count(huck_finn_chapters, 'Huck')\n", + " 'Jim', np.cumsum(np.char.count(huck_finn_chapters, 'Jim')),\n", + " 'Tom', np.cumsum(np.char.count(huck_finn_chapters, 'Tom')),\n", + " 'Huck', np.cumsum(np.char.count(huck_finn_chapters, 'Huck'))\n", " ])\n", "\n", "# Plot the cumulative counts:\n", "# how many times in Chapter 1, how many times in Chapters 1 and 2, and so on.\n", "\n", - "cum_counts = counts.cumsum().with_column('Chapter', np.arange(1, 44, 1))\n", + "cum_counts = counts.with_column('Chapter', np.arange(1, 44, 1))\n", "cum_counts.plot(column_for_xticks=3)\n", - "plots.title('Cumulative Number of Times Each Name Appears', y=1.08);" + "plots.title('Cumulative Number of Times Each Name Appears', y=1.08)" ] }, { @@ -207,22 +207,22 @@ } ], "source": [ - "# Counts of names in the chapters of Little Women\n", + "# Get the cumulative counts of the names in the chapters of Little Women\n", "\n", "counts = Table().with_columns([\n", - " 'Amy', np.char.count(little_women_chapters, 'Amy'),\n", - " 'Beth', np.char.count(little_women_chapters, 'Beth'),\n", - " 'Jo', np.char.count(little_women_chapters, 'Jo'),\n", - " 'Meg', np.char.count(little_women_chapters, 'Meg'),\n", - " 'Laurie', np.char.count(little_women_chapters, 'Laurie'),\n", + " 'Amy', np.cumsum(np.char.count(little_women_chapters, 'Amy')),\n", + " 'Beth', np.cumsum(np.char.count(little_women_chapters, 'Beth')),\n", + " 'Jo', np.cumsum(np.char.count(little_women_chapters, 'Jo')),\n", + " 'Meg', np.cumsum(np.char.count(little_women_chapters, 'Meg')),\n", + " 'Laurie', np.cumsum(np.char.count(little_women_chapters, 'Laurie')),\n", "\n", " ])\n", "\n", "# Plot the cumulative counts.\n", "\n", - "cum_counts = counts.cumsum().with_column('Chapter', np.arange(1, 48, 1))\n", + "cum_counts = counts.with_column('Chapter', np.arange(1, 48, 1))\n", "cum_counts.plot(column_for_xticks=5)\n", - "plots.title('Cumulative Number of Times Each Name Appears', y=1.08);" + "plots.title('Cumulative Number of Times Each Name Appears', y=1.08)" ] }, {