Skip to content

Commit

Permalink
Typo nits. Update cumulative lit graph b/c of loss of cumsum
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Rizzi committed Aug 13, 2023
1 parent c88d658 commit 8a5f2d1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion chapters/01/2/why-data-science.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 15 additions & 15 deletions chapters/01/3/1/Literary_Characters.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)"
]
},
{
Expand Down Expand Up @@ -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)"
]
},
{
Expand Down

0 comments on commit 8a5f2d1

Please sign in to comment.