Skip to content

Commit fbea331

Browse files
update old posts
1 parent be8f8db commit fbea331

21 files changed

+62
-49
lines changed

Chapter1/code_speed.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@
237237
"name": "python",
238238
"nbconvert_exporter": "python",
239239
"pygments_lexer": "ipython3",
240-
"version": "3.9.6"
240+
"version": "3.11.6"
241241
},
242242
"toc": {
243243
"base_numbering": 1,

Chapter1/good_practices.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1981,7 +1981,7 @@
19811981
"name": "python",
19821982
"nbconvert_exporter": "python",
19831983
"pygments_lexer": "ipython3",
1984-
"version": "3.9.6"
1984+
"version": "3.11.6"
19851985
},
19861986
"toc": {
19871987
"base_numbering": 1,

Chapter1/list/apply_functions_to_elements.ipynb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,12 @@
204204
"id": "c45f86ed",
205205
"metadata": {},
206206
"source": [
207-
"If you want to sort a list of tuples by the first or second item in a tuple, use the `sort` method. To specify which item to sort by, use the `key` parameter."
207+
"To sort a list of tuples, use the `sort()` method and pass in the key parameter to indicate which item to sort by."
208208
]
209209
},
210210
{
211211
"cell_type": "code",
212-
"execution_count": 8,
212+
"execution_count": 1,
213213
"id": "a8553089",
214214
"metadata": {
215215
"ExecuteTime": {
@@ -221,16 +221,16 @@
221221
{
222222
"data": {
223223
"text/plain": [
224-
"[('apple', 3), ('banana', 2), ('grape', 3), ('orange', 1)]"
224+
"[('banana', 2), ('grape', 3), ('orange', 1)]"
225225
]
226226
},
227-
"execution_count": 8,
227+
"execution_count": 1,
228228
"metadata": {},
229229
"output_type": "execute_result"
230230
}
231231
],
232232
"source": [
233-
"prices = [('apple', 3), ('orange', 1), ('grape', 3), ('banana', 2)]\n",
233+
"prices = [('orange', 1), ('grape', 3), ('banana', 2)]\n",
234234
"\n",
235235
"# Sort by the first item\n",
236236
"by_letter = lambda x: x[0]\n",
@@ -240,7 +240,7 @@
240240
},
241241
{
242242
"cell_type": "code",
243-
"execution_count": 9,
243+
"execution_count": 3,
244244
"id": "f9cb2e79",
245245
"metadata": {
246246
"ExecuteTime": {
@@ -252,18 +252,18 @@
252252
{
253253
"data": {
254254
"text/plain": [
255-
"[('apple', 3), ('grape', 3), ('banana', 2), ('orange', 1)]"
255+
"[('orange', 1), ('banana', 2), ('grape', 3)]"
256256
]
257257
},
258-
"execution_count": 9,
258+
"execution_count": 3,
259259
"metadata": {},
260260
"output_type": "execute_result"
261261
}
262262
],
263263
"source": [
264-
"# Sort by the second item in reversed order\n",
264+
"# Sort by the second item\n",
265265
"by_price = lambda x: x[1]\n",
266-
"prices.sort(key=by_price, reverse=True)\n",
266+
"prices.sort(key=by_price)\n",
267267
"prices"
268268
]
269269
},
@@ -376,7 +376,7 @@
376376
"name": "python",
377377
"nbconvert_exporter": "python",
378378
"pygments_lexer": "ipython3",
379-
"version": "3.9.6"
379+
"version": "3.11.6"
380380
},
381381
"toc": {
382382
"base_numbering": 1,

Chapter1/list/interaction_between_2_lists.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@
180180
"name": "python",
181181
"nbconvert_exporter": "python",
182182
"pygments_lexer": "ipython3",
183-
"version": "3.9.6"
183+
"version": "3.11.6"
184184
},
185185
"toc": {
186186
"base_numbering": 1,

Chapter1/list/unpack_iterables.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@
183183
"name": "python",
184184
"nbconvert_exporter": "python",
185185
"pygments_lexer": "ipython3",
186-
"version": "3.9.6"
186+
"version": "3.11.6"
187187
},
188188
"toc": {
189189
"base_numbering": 1,

Chapter5/natural_language_processing.ipynb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@
682682
"id": "040bd4b1",
683683
"metadata": {},
684684
"source": [
685-
"### Convert Number to Words\n"
685+
"### Num2Words: Convert Number to Words\n"
686686
]
687687
},
688688
{
@@ -705,7 +705,9 @@
705705
"id": "aef1c93b",
706706
"metadata": {},
707707
"source": [
708-
"If there are both number 2019 and the words 'two thousand and nineteen' in a text, they should deliver the same meaning. How can we map 2019 to 'two thousand and nineteen'? There is a Python libary to convert number to words called `num2words`."
708+
"When data contains both a numerical value (2019) and a written expression ('two thousand and nineteen') that represent the same quantity, it's essential for them to match for accurate NLP interpretation.\n",
709+
"\n",
710+
"This can be achieved by using num2words, which helps convert numbers to their word equivalent."
709711
]
710712
},
711713
{
@@ -871,7 +873,7 @@
871873
"id": "56643f49",
872874
"metadata": {},
873875
"source": [
874-
"[Link to num2words](https://github.com/savoirfairelinux/num2words)."
876+
"[Link to num2words](https://bit.ly/3VkWYJO)."
875877
]
876878
},
877879
{

docs/Chapter1/Chapter1.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@
234234
<li class="toctree-l2"><a class="reference internal" href="../Chapter2/dataclasses.html">3.7. Data Classes</a></li>
235235
<li class="toctree-l2"><a class="reference internal" href="../Chapter2/typing.html">3.8. Typing</a></li>
236236
<li class="toctree-l2"><a class="reference internal" href="../Chapter2/pathlib.html">3.9. pathlib</a></li>
237+
<li class="toctree-l2"><a class="reference internal" href="../Chapter2/pydantic.html">3.10. Pydantic</a></li>
237238
</ul>
238239
</li>
239240
<li class="toctree-l1 has-children"><a class="reference internal" href="../Chapter3/Chapter3.html">4. Pandas</a><input class="toctree-checkbox" id="toctree-checkbox-4" name="toctree-checkbox-4" type="checkbox"/><label class="toctree-toggle" for="toctree-checkbox-4"><i class="fa-solid fa-chevron-down"></i></label><ul>

docs/Chapter1/code_speed.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@
234234
<li class="toctree-l2"><a class="reference internal" href="../Chapter2/dataclasses.html">3.7. Data Classes</a></li>
235235
<li class="toctree-l2"><a class="reference internal" href="../Chapter2/typing.html">3.8. Typing</a></li>
236236
<li class="toctree-l2"><a class="reference internal" href="../Chapter2/pathlib.html">3.9. pathlib</a></li>
237+
<li class="toctree-l2"><a class="reference internal" href="../Chapter2/pydantic.html">3.10. Pydantic</a></li>
237238
</ul>
238239
</li>
239240
<li class="toctree-l1 has-children"><a class="reference internal" href="../Chapter3/Chapter3.html">4. Pandas</a><input class="toctree-checkbox" id="toctree-checkbox-4" name="toctree-checkbox-4" type="checkbox"/><label class="toctree-toggle" for="toctree-checkbox-4"><i class="fa-solid fa-chevron-down"></i></label><ul>

docs/Chapter1/good_practices.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@
234234
<li class="toctree-l2"><a class="reference internal" href="../Chapter2/dataclasses.html">3.7. Data Classes</a></li>
235235
<li class="toctree-l2"><a class="reference internal" href="../Chapter2/typing.html">3.8. Typing</a></li>
236236
<li class="toctree-l2"><a class="reference internal" href="../Chapter2/pathlib.html">3.9. pathlib</a></li>
237+
<li class="toctree-l2"><a class="reference internal" href="../Chapter2/pydantic.html">3.10. Pydantic</a></li>
237238
</ul>
238239
</li>
239240
<li class="toctree-l1 has-children"><a class="reference internal" href="../Chapter3/Chapter3.html">4. Pandas</a><input class="toctree-checkbox" id="toctree-checkbox-4" name="toctree-checkbox-4" type="checkbox"/><label class="toctree-toggle" for="toctree-checkbox-4"><i class="fa-solid fa-chevron-down"></i></label><ul>

docs/Chapter1/list/apply_functions_to_elements.html

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@
234234
<li class="toctree-l2"><a class="reference internal" href="../../Chapter2/dataclasses.html">3.7. Data Classes</a></li>
235235
<li class="toctree-l2"><a class="reference internal" href="../../Chapter2/typing.html">3.8. Typing</a></li>
236236
<li class="toctree-l2"><a class="reference internal" href="../../Chapter2/pathlib.html">3.9. pathlib</a></li>
237+
<li class="toctree-l2"><a class="reference internal" href="../../Chapter2/pydantic.html">3.10. Pydantic</a></li>
237238
</ul>
238239
</li>
239240
<li class="toctree-l1 has-children"><a class="reference internal" href="../../Chapter3/Chapter3.html">4. Pandas</a><input class="toctree-checkbox" id="toctree-checkbox-4" name="toctree-checkbox-4" type="checkbox"/><label class="toctree-toggle" for="toctree-checkbox-4"><i class="fa-solid fa-chevron-down"></i></label><ul>
@@ -606,10 +607,10 @@ <h2><span class="section-number">2.3.5.4. </span>map method: Apply a Function to
606607
</section>
607608
<section id="sort-sort-a-list-of-tuples-by-the-first-or-second-item">
608609
<h2><span class="section-number">2.3.5.5. </span>sort: Sort a List of Tuples by the First or Second Item<a class="headerlink" href="#sort-sort-a-list-of-tuples-by-the-first-or-second-item" title="Permalink to this heading">#</a></h2>
609-
<p>If you want to sort a list of tuples by the first or second item in a tuple, use the <code class="docutils literal notranslate"><span class="pre">sort</span></code> method. To specify which item to sort by, use the <code class="docutils literal notranslate"><span class="pre">key</span></code> parameter.</p>
610+
<p>To sort a list of tuples, use the <code class="docutils literal notranslate"><span class="pre">sort()</span></code> method and pass in the key parameter to indicate which item to sort by.</p>
610611
<div class="cell docutils container">
611612
<div class="cell_input docutils container">
612-
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">prices</span> <span class="o">=</span> <span class="p">[(</span><span class="s1">&#39;apple&#39;</span><span class="p">,</span> <span class="mi">3</span><span class="p">),</span> <span class="p">(</span><span class="s1">&#39;orange&#39;</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="p">(</span><span class="s1">&#39;grape&#39;</span><span class="p">,</span> <span class="mi">3</span><span class="p">),</span> <span class="p">(</span><span class="s1">&#39;banana&#39;</span><span class="p">,</span> <span class="mi">2</span><span class="p">)]</span>
613+
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">prices</span> <span class="o">=</span> <span class="p">[(</span><span class="s1">&#39;orange&#39;</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="p">(</span><span class="s1">&#39;grape&#39;</span><span class="p">,</span> <span class="mi">3</span><span class="p">),</span> <span class="p">(</span><span class="s1">&#39;banana&#39;</span><span class="p">,</span> <span class="mi">2</span><span class="p">)]</span>
613614

614615
<span class="c1"># Sort by the first item</span>
615616
<span class="n">by_letter</span> <span class="o">=</span> <span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="n">x</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
@@ -619,22 +620,22 @@ <h2><span class="section-number">2.3.5.5. </span>sort: Sort a List of Tuples by
619620
</div>
620621
</div>
621622
<div class="cell_output docutils container">
622-
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[(&#39;apple&#39;, 3), (&#39;banana&#39;, 2), (&#39;grape&#39;, 3), (&#39;orange&#39;, 1)]
623+
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[(&#39;banana&#39;, 2), (&#39;grape&#39;, 3), (&#39;orange&#39;, 1)]
623624
</pre></div>
624625
</div>
625626
</div>
626627
</div>
627628
<div class="cell docutils container">
628629
<div class="cell_input docutils container">
629-
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Sort by the second item in reversed order</span>
630+
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Sort by the second item</span>
630631
<span class="n">by_price</span> <span class="o">=</span> <span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="n">x</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
631-
<span class="n">prices</span><span class="o">.</span><span class="n">sort</span><span class="p">(</span><span class="n">key</span><span class="o">=</span><span class="n">by_price</span><span class="p">,</span> <span class="n">reverse</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
632+
<span class="n">prices</span><span class="o">.</span><span class="n">sort</span><span class="p">(</span><span class="n">key</span><span class="o">=</span><span class="n">by_price</span><span class="p">)</span>
632633
<span class="n">prices</span>
633634
</pre></div>
634635
</div>
635636
</div>
636637
<div class="cell_output docutils container">
637-
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[(&#39;apple&#39;, 3), (&#39;grape&#39;, 3), (&#39;banana&#39;, 2), (&#39;orange&#39;, 1)]
638+
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[(&#39;orange&#39;, 1), (&#39;banana&#39;, 2), (&#39;grape&#39;, 3)]
638639
</pre></div>
639640
</div>
640641
</div>

0 commit comments

Comments
 (0)