Skip to content
182 changes: 85 additions & 97 deletions chapters/01/3/1/Literary_Characters.ipynb

Large diffs are not rendered by default.

223 changes: 85 additions & 138 deletions chapters/01/3/2/Another_Kind_Of_Character.ipynb

Large diffs are not rendered by default.

112 changes: 48 additions & 64 deletions chapters/01/3/Plotting_the_Classics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
},
"outputs": [],
"source": [
"from datascience import *\n",
"from datascience.predicates import are\n",
"import polars as pl\n",
"path_data = '../../../../data/'\n",
"import numpy as np\n",
"import matplotlib\n",
"matplotlib.use('Agg')\n",
"%matplotlib inline\n",
Expand Down Expand Up @@ -67,7 +65,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"While a computer cannot understand the text of a book, it can provide us with some insight into the structure of the text. The name `huck_finn_chapters` is currently bound to a list of all the chapters in the book. We can place them into a table to see how each chapter begins."
"While a computer cannot understand the text of a book, it can provide us with some insight into the structure of the text. The name `huck_finn_chapters` is currently bound to a list of all the chapters in the book. We can place them into a DataFrame to see how each chapter begins."
]
},
{
Expand All @@ -76,73 +74,59 @@
"metadata": {},
"outputs": [
{
"output_type": "execute_result",
"execution_count": 3,
"metadata": {},
"data": {
"text/html": [
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr>\n",
" <th>Chapters</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <td>I. YOU don't know about me without you have read a book ...</td>\n",
" </tr>\n",
" <tr>\n",
" <td>II. WE went tiptoeing along a path amongst the trees bac ...</td>\n",
" </tr>\n",
" <tr>\n",
" <td>III. WELL, I got a good going-over in the morning from o ...</td>\n",
" </tr>\n",
" <tr>\n",
" <td>IV. WELL, three or four months run along, and it was wel ...</td>\n",
" </tr>\n",
" <tr>\n",
" <td>V. I had shut the door to. Then I turned around and ther ...</td>\n",
" </tr>\n",
" <tr>\n",
" <td>VI. WELL, pretty soon the old man was up and around agai ...</td>\n",
" </tr>\n",
" <tr>\n",
" <td>VII. \"GIT up! What you 'bout?\" I opened my eyes and look ...</td>\n",
" </tr>\n",
" <tr>\n",
" <td>VIII. THE sun was up so high when I waked that I judged ...</td>\n",
" </tr>\n",
" <tr>\n",
" <td>IX. I wanted to go and look at a place right about the m ...</td>\n",
" </tr>\n",
" <tr>\n",
" <td>X. AFTER breakfast I wanted to talk about the dead man a ...</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>... (33 rows omitted)</p>"
],
"text/plain": [
"Chapters\n",
"I. YOU don't know about me without you have read a book ...\n",
"II. WE went tiptoeing along a path amongst the trees bac ...\n",
"III. WELL, I got a good going-over in the morning from o ...\n",
"IV. WELL, three or four months run along, and it was wel ...\n",
"V. I had shut the door to. Then I turned around and ther ...\n",
"VI. WELL, pretty soon the old man was up and around agai ...\n",
"VII. \"GIT up! What you 'bout?\" I opened my eyes and look ...\n",
"VIII. THE sun was up so high when I waked that I judged ...\n",
"IX. I wanted to go and look at a place right about the m ...\n",
"X. AFTER breakfast I wanted to talk about the dead man a ...\n",
"... (33 rows omitted)"
"shape: (43, 1)\n",
"┌──────────────────────────────────────────────────────────────────────────────────────────────────┐\n",
"│ Chapters │\n",
"│ --- │\n",
"│ str │\n",
"╞══════════════════════════════════════════════════════════════════════════════════════════════════╡\n",
"│ I. YOU don't know about me without you have read a book by the name of The Adventures of Tom │\n",
"│ Sawyer; but that ain't no matter. That book was made by Mr. Mark Tw… │\n",
"│ II. WE went tiptoeing along a path amongst the trees back towards the end of the widow's garden, │\n",
"│ stooping down so as the branches wouldn't scrape our heads. Whe… │\n",
"│ III. WELL, I got a good going-over in the morning from old Miss Watson on account of my clothes; │\n",
"│ but the widow she didn't scold, but only cleaned off the grease… │\n",
"│ IV. WELL, three or four months run along, and it was well into the winter now. I had been to │\n",
"│ school most all the time and could spell and read and write just a … │\n",
"│ V. I had shut the door to. Then I turned around and there he was. I used to be scared of him all │\n",
"│ the time, he tanned me so much. I reckoned I was scared now, to… │\n",
"│ … │\n",
"│ XXXIX. IN the morning we went up to the village and bought a wire rat-trap and fetched it down, │\n",
"│ and unstopped the best rat-hole, and in about an hour we had fif… │\n",
"│ XL. WE was feeling pretty good after breakfast, and took my canoe and went over the river │\n",
"│ a-fishing, with a lunch, and had a good time, and took a look at the r… │\n",
"│ XLI. THE doctor was an old man; a very nice, kind-looking old man when I got him up. I told him │\n",
"│ me and my brother was over on Spanish Island hunting yesterday a… │\n",
"│ XLII. THE old man was uptown again before breakfast, but couldn't get no track of Tom; and both │\n",
"│ of them set at the table thinking, and not saying nothing, and l… │\n",
"│ THE LAST THE first time I catched Tom private I asked him what was his idea, time of the │\n",
"│ evasion?--what it was he'd planned to do if the evasion worked all righ… │\n",
"└──────────────────────────────────────────────────────────────────────────────────────────────────┘"
],
"text/html": [
"<div><style>\n",
".dataframe > thead > tr,\n",
".dataframe > tbody > tr {\n",
" text-align: right;\n",
" white-space: pre-wrap;\n",
"}\n",
"</style>\n",
"<small>shape: (43, 1)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>Chapters</th></tr><tr><td>str</td></tr></thead><tbody><tr><td>&quot;I. YOU don&#x27;t know about me without you have read a book by the name of The Adventures of Tom Sawyer; but that ain&#x27;t no matter. That book was made by Mr. Mark Tw…</td></tr><tr><td>&quot;II. WE went tiptoeing along a path amongst the trees back towards the end of the widow&#x27;s garden, stooping down so as the branches wouldn&#x27;t scrape our heads. Whe…</td></tr><tr><td>&quot;III. WELL, I got a good going-over in the morning from old Miss Watson on account of my clothes; but the widow she didn&#x27;t scold, but only cleaned off the grease…</td></tr><tr><td>&quot;IV. WELL, three or four months run along, and it was well into the winter now. I had been to school most all the time and could spell and read and write just a …</td></tr><tr><td>&quot;V. I had shut the door to. Then I turned around and there he was. I used to be scared of him all the time, he tanned me so much. I reckoned I was scared now, to…</td></tr><tr><td>&hellip;</td></tr><tr><td>&quot;XXXIX. IN the morning we went up to the village and bought a wire rat-trap and fetched it down, and unstopped the best rat-hole, and in about an hour we had fif…</td></tr><tr><td>&quot;XL. WE was feeling pretty good after breakfast, and took my canoe and went over the river a-fishing, with a lunch, and had a good time, and took a look at the r…</td></tr><tr><td>&quot;XLI. THE doctor was an old man; a very nice, kind-looking old man when I got him up. I told him me and my brother was over on Spanish Island hunting yesterday a…</td></tr><tr><td>&quot;XLII. THE old man was uptown again before breakfast, but couldn&#x27;t get no track of Tom; and both of them set at the table thinking, and not saying nothing, and l…</td></tr><tr><td>&quot;THE LAST THE first time I catched Tom private I asked him what was his idea, time of the evasion?--what it was he&#x27;d planned to do if the evasion worked all righ…</td></tr></tbody></table></div>"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
}
],
"source": [
"# Display the chapters of Huckleberry Finn in a table.\n",
"# Display the chapters of Huckleberry Finn in a DataFrame.\n",
"\n",
"Table().with_column('Chapters', huck_finn_chapters)"
"# POLARS_CHANGE: show enough of each chapter string to include the opening sentence\n",
"with pl.Config(fmt_str_lengths=160):\n",
" display(pl.DataFrame([pl.Series(\"Chapters\", huck_finn_chapters)]))"
]
},
{
Expand Down
Loading
Loading