Skip to content

Commit

Permalink
deploy: 134e6af
Browse files Browse the repository at this point in the history
  • Loading branch information
pnavaro committed Sep 11, 2023
1 parent fcf2752 commit 1ea4a14
Show file tree
Hide file tree
Showing 62 changed files with 2,549 additions and 2,641 deletions.
95 changes: 48 additions & 47 deletions 01-GitBasics.html

Large diffs are not rendered by default.

166 changes: 69 additions & 97 deletions 02-Installation.html

Large diffs are not rendered by default.

25 changes: 13 additions & 12 deletions 03-JupyterQuickStart.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!DOCTYPE html>


<html >
<html lang="en" >

<head>
<meta charset="utf-8" />
Expand Down Expand Up @@ -44,6 +44,7 @@
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js"></script>
<script src="_static/doctools.js"></script>
<script src="_static/clipboard.min.js"></script>
<script src="_static/copybutton.js"></script>
Expand All @@ -67,7 +68,7 @@
<link rel="next" title="Wordcount" href="04-WordCount.html" />
<link rel="prev" title="Installation" href="02-Installation.html" />
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="docsearch:language" content="None"/>
<meta name="docsearch:language" content="en"/>
</head>


Expand Down Expand Up @@ -471,10 +472,10 @@ <h2> Contents </h2>
<article class="bd-article" role="main">

<section class="tex2jax_ignore mathjax_ignore" id="jupyter">
<h1>Jupyter<a class="headerlink" href="#jupyter" title="Permalink to this headline">#</a></h1>
<h1>Jupyter<a class="headerlink" href="#jupyter" title="Permalink to this heading">#</a></h1>
<p><img alt="jupyter" src="_images/jupyter-logo.png" /></p>
<section id="launch-jupyter-server">
<h2>Launch Jupyter server<a class="headerlink" href="#launch-jupyter-server" title="Permalink to this headline">#</a></h2>
<h2>Launch Jupyter server<a class="headerlink" href="#launch-jupyter-server" title="Permalink to this heading">#</a></h2>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>jupyter<span class="w"> </span>notebook
</pre></div>
</div>
Expand All @@ -484,18 +485,18 @@ <h2>Launch Jupyter server<a class="headerlink" href="#launch-jupyter-server" tit
</ul>
</section>
<section id="make-a-copy">
<h2>Make a Copy<a class="headerlink" href="#make-a-copy" title="Permalink to this headline">#</a></h2>
<h2>Make a Copy<a class="headerlink" href="#make-a-copy" title="Permalink to this heading">#</a></h2>
<p>Before modifying the notebook, make a copy of it. Go to to <code class="docutils literal notranslate"><span class="pre">File</span></code> menu
on the top left of the notebook and click on <code class="docutils literal notranslate"><span class="pre">Make</span> <span class="pre">a</span> <span class="pre">Copy...</span></code></p>
</section>
<section id="jupyter-notebook">
<h2>Jupyter Notebook<a class="headerlink" href="#jupyter-notebook" title="Permalink to this headline">#</a></h2>
<h2>Jupyter Notebook<a class="headerlink" href="#jupyter-notebook" title="Permalink to this heading">#</a></h2>
<p>Jupyter notebook, formerly known as the IPython notebook, is a flexible tool that helps you create readable analyses, as you can keep code, images, comments, formulae and plots together.</p>
<p>Jupyter is quite extensible, supports many programming languages and is easily hosted on your computer or on almost any server — you only need to have ssh or http access. Best of all, it’s completely free.</p>
<p>The name Jupyter is an indirect acronyum of the three core languages it was designed for: <strong>JU</strong>lia, <strong>PYT</strong>hon, and <strong>R</strong></p>
</section>
<section id="keyboard-shortcuts">
<h2>Keyboard Shortcuts<a class="headerlink" href="#keyboard-shortcuts" title="Permalink to this headline">#</a></h2>
<h2>Keyboard Shortcuts<a class="headerlink" href="#keyboard-shortcuts" title="Permalink to this heading">#</a></h2>
<ul class="simple">
<li><p>To access keyboard shortcuts, use the command palette: <code class="docutils literal notranslate"><span class="pre">Cmd</span> <span class="pre">+</span> <span class="pre">Shift</span> <span class="pre">+</span> <span class="pre">P</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">Esc</span></code> will take you into command mode where you can navigate around your notebook with arrow keys.</p></li>
Expand All @@ -509,7 +510,7 @@ <h2>Keyboard Shortcuts<a class="headerlink" href="#keyboard-shortcuts" title="Pe
</ul>
</section>
<section id="easy-links-to-documentation">
<h2>Easy links to documentation<a class="headerlink" href="#easy-links-to-documentation" title="Permalink to this headline">#</a></h2>
<h2>Easy links to documentation<a class="headerlink" href="#easy-links-to-documentation" title="Permalink to this heading">#</a></h2>
<ul class="simple">
<li><p>Shift + Tab will also show you the Docstring</p></li>
</ul>
Expand All @@ -522,7 +523,7 @@ <h2>Easy links to documentation<a class="headerlink" href="#easy-links-to-docume
</div>
</section>
<section id="magic-commands">
<h2>Magic commands<a class="headerlink" href="#magic-commands" title="Permalink to this headline">#</a></h2>
<h2>Magic commands<a class="headerlink" href="#magic-commands" title="Permalink to this heading">#</a></h2>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="o">%</span><span class="n">lsmagic</span>
Expand Down Expand Up @@ -599,16 +600,16 @@ <h2>Magic commands<a class="headerlink" href="#magic-commands" title="Permalink
</div>
</section>
<section id="installing-python-packages-from-a-jupyter-notebook">
<h2>Installing Python Packages from a Jupyter Notebook<a class="headerlink" href="#installing-python-packages-from-a-jupyter-notebook" title="Permalink to this headline">#</a></h2>
<h2>Installing Python Packages from a Jupyter Notebook<a class="headerlink" href="#installing-python-packages-from-a-jupyter-notebook" title="Permalink to this heading">#</a></h2>
<section id="install-a-conda-package-in-the-current-jupyter-kernel">
<h3>Install a conda package in the current Jupyter kernel<a class="headerlink" href="#install-a-conda-package-in-the-current-jupyter-kernel" title="Permalink to this headline">#</a></h3>
<h3>Install a conda package in the current Jupyter kernel<a class="headerlink" href="#install-a-conda-package-in-the-current-jupyter-kernel" title="Permalink to this heading">#</a></h3>
<p>Example with package <code class="docutils literal notranslate"><span class="pre">numpy</span></code> from <em>conda-forge</em></p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">%</span><span class="n">conda</span> <span class="n">install</span> <span class="o">-</span><span class="n">c</span> <span class="n">conda</span><span class="o">-</span><span class="n">forge</span> <span class="n">numpy</span>
</pre></div>
</div>
</section>
<section id="install-a-pip-package-in-the-current-jupyter-kernel">
<h3>Install a pip package in the current Jupyter kernel<a class="headerlink" href="#install-a-pip-package-in-the-current-jupyter-kernel" title="Permalink to this headline">#</a></h3>
<h3>Install a pip package in the current Jupyter kernel<a class="headerlink" href="#install-a-pip-package-in-the-current-jupyter-kernel" title="Permalink to this heading">#</a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">%</span><span class="n">pip</span> <span class="n">install</span> <span class="n">numpy</span>
</pre></div>
</div>
Expand Down
33 changes: 17 additions & 16 deletions 04-WordCount.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!DOCTYPE html>


<html >
<html lang="en" >

<head>
<meta charset="utf-8" />
Expand Down Expand Up @@ -44,6 +44,7 @@
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js"></script>
<script src="_static/doctools.js"></script>
<script src="_static/clipboard.min.js"></script>
<script src="_static/copybutton.js"></script>
Expand All @@ -67,7 +68,7 @@
<link rel="next" title="Map Reduce" href="05-MapReduce.html" />
<link rel="prev" title="Jupyter" href="03-JupyterQuickStart.html" />
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="docsearch:language" content="None"/>
<meta name="docsearch:language" content="en"/>
</head>


Expand Down Expand Up @@ -481,7 +482,7 @@ <h2> Contents </h2>
<article class="bd-article" role="main">

<section class="tex2jax_ignore mathjax_ignore" id="wordcount">
<h1>Wordcount<a class="headerlink" href="#wordcount" title="Permalink to this headline">#</a></h1>
<h1>Wordcount<a class="headerlink" href="#wordcount" title="Permalink to this heading">#</a></h1>
<ul class="simple">
<li><p><a class="reference external" href="https://en.wikipedia.org/wiki/Word_count">Wikipedia</a></p></li>
<li><p>Word count example reads text files and counts how often words occur.</p></li>
Expand All @@ -496,7 +497,7 @@ <h1>Wordcount<a class="headerlink" href="#wordcount" title="Permalink to this he
<li><p><em>Notebooks will be updated every week with solutions</em></p></li>
</ul>
<section id="create-sample-text-file">
<h2>Create sample text file<a class="headerlink" href="#create-sample-text-file" title="Permalink to this headline">#</a></h2>
<h2>Create sample text file<a class="headerlink" href="#create-sample-text-file" title="Permalink to this heading">#</a></h2>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">lorem</span> <span class="kn">import</span> <span class="n">text</span>
Expand All @@ -509,7 +510,7 @@ <h2>Create sample text file<a class="headerlink" href="#create-sample-text-file"
</div>
</div>
<section id="exercise-4-1">
<h3>Exercise 4.1<a class="headerlink" href="#exercise-4-1" title="Permalink to this headline">#</a></h3>
<h3>Exercise 4.1<a class="headerlink" href="#exercise-4-1" title="Permalink to this heading">#</a></h3>
<p>Write a python program that counts the number of lines, different words and characters in that file.</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
Expand All @@ -522,7 +523,7 @@ <h3>Exercise 4.1<a class="headerlink" href="#exercise-4-1" title="Permalink to t
</div>
</section>
<section id="exercise-4-2">
<h3>Exercise 4.2<a class="headerlink" href="#exercise-4-2" title="Permalink to this headline">#</a></h3>
<h3>Exercise 4.2<a class="headerlink" href="#exercise-4-2" title="Permalink to this heading">#</a></h3>
<p>Create a function called <code class="docutils literal notranslate"><span class="pre">map_words</span></code> that take a file name as argument and return a lists containing all words as items.</p>
<div class="highlight-pytb notranslate"><div class="highlight"><pre><span></span><span class="x">map_words(&quot;sample.txt&quot;)[:5] # first five words</span>
<span class="x">[&#39;adipisci&#39;, &#39;adipisci&#39;, &#39;adipisci&#39;, &#39;adipisci&#39;, &#39;adipisci&#39;]</span>
Expand All @@ -531,7 +532,7 @@ <h3>Exercise 4.2<a class="headerlink" href="#exercise-4-2" title="Permalink to t
</section>
</section>
<section id="sorting-a-dictionary-by-value">
<h2>Sorting a dictionary by value<a class="headerlink" href="#sorting-a-dictionary-by-value" title="Permalink to this headline">#</a></h2>
<h2>Sorting a dictionary by value<a class="headerlink" href="#sorting-a-dictionary-by-value" title="Permalink to this heading">#</a></h2>
<p>By default, if you use <code class="docutils literal notranslate"><span class="pre">sorted</span></code> function on a <code class="docutils literal notranslate"><span class="pre">dict</span></code>, it will use keys to sort it.
To sort by values, you can use <a class="reference external" href="https://docs.python.org/3.6/library/operator.html">operator</a>.itemgetter(1)
Return a callable object that fetches item from its operand using the operand’s <code class="docutils literal notranslate"><span class="pre">__getitem__(</span></code> method. It could be used to sort results.</p>
Expand All @@ -554,7 +555,7 @@ <h2>Sorting a dictionary by value<a class="headerlink" href="#sorting-a-dictiona
</div>
</div>
<section id="exercise-4-3">
<h3>Exercise 4.3<a class="headerlink" href="#exercise-4-3" title="Permalink to this headline">#</a></h3>
<h3>Exercise 4.3<a class="headerlink" href="#exercise-4-3" title="Permalink to this heading">#</a></h3>
<p>Create a function <code class="docutils literal notranslate"><span class="pre">reduce</span></code> to reduce the list of words returned by <code class="docutils literal notranslate"><span class="pre">map_words</span></code> and return a dictionary containing all words as keys and number of occurrences as values.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">recuce</span><span class="p">(</span><span class="s1">&#39;sample.txt&#39;</span><span class="p">)</span>
<span class="p">{</span><span class="s1">&#39;tempora&#39;</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span> <span class="s1">&#39;non&#39;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="s1">&#39;quisquam&#39;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="s1">&#39;amet&#39;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="s1">&#39;sit&#39;</span><span class="p">:</span> <span class="mi">1</span><span class="p">}</span>
Expand All @@ -564,14 +565,14 @@ <h3>Exercise 4.3<a class="headerlink" href="#exercise-4-3" title="Permalink to t
</section>
</section>
<section id="container-datatypes">
<h2>Container datatypes<a class="headerlink" href="#container-datatypes" title="Permalink to this headline">#</a></h2>
<h2>Container datatypes<a class="headerlink" href="#container-datatypes" title="Permalink to this heading">#</a></h2>
<p><code class="docutils literal notranslate"><span class="pre">collection</span></code> module implements specialized container datatypes providing alternatives to Python’s general purpose built-in containers, <code class="docutils literal notranslate"><span class="pre">dict</span></code>, <code class="docutils literal notranslate"><span class="pre">list</span></code>, <code class="docutils literal notranslate"><span class="pre">set</span></code>, and <code class="docutils literal notranslate"><span class="pre">tuple</span></code>.</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">defaultdict</span></code> : dict subclass that calls a factory function to supply missing values</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">Counter</span></code> : dict subclass for counting hashable objects</p></li>
</ul>
<section id="defaultdict">
<h3>defaultdict<a class="headerlink" href="#defaultdict" title="Permalink to this headline">#</a></h3>
<h3>defaultdict<a class="headerlink" href="#defaultdict" title="Permalink to this heading">#</a></h3>
<p>When you implement the <code class="docutils literal notranslate"><span class="pre">wordcount</span></code> function you probably had some problem to append key-value pair to your <code class="docutils literal notranslate"><span class="pre">dict</span></code>. If you try to change the value of a key that is not present
in the dict, the key is not automatically created.</p>
<p>You can use a <code class="docutils literal notranslate"><span class="pre">try-except</span></code> flow but the <code class="docutils literal notranslate"><span class="pre">defaultdict</span></code> could be a solution. This container is a <code class="docutils literal notranslate"><span class="pre">dict</span></code> subclass that calls a factory function to supply missing values.
Expand All @@ -591,13 +592,13 @@ <h3>defaultdict<a class="headerlink" href="#defaultdict" title="Permalink to thi
</div>
</section>
<section id="exercise-4-4">
<h3>Exercise 4.4<a class="headerlink" href="#exercise-4-4" title="Permalink to this headline">#</a></h3>
<h3>Exercise 4.4<a class="headerlink" href="#exercise-4-4" title="Permalink to this heading">#</a></h3>
<ul class="simple">
<li><p>Modify the <code class="docutils literal notranslate"><span class="pre">reduce</span></code> function you wrote above by using a defaultdict with the most suitable factory.</p></li>
</ul>
</section>
<section id="counter">
<h3>Counter<a class="headerlink" href="#counter" title="Permalink to this headline">#</a></h3>
<h3>Counter<a class="headerlink" href="#counter" title="Permalink to this heading">#</a></h3>
<p>A Counter is a dict subclass for counting hashable objects. It is an unordered collection where elements are stored as dictionary keys and their counts are stored as dictionary values. Counts are allowed to be any integer value including zero or negative counts.</p>
<p>Elements are counted from an iterable or initialized from another mapping (or counter):</p>
<div class="cell docutils container">
Expand Down Expand Up @@ -636,13 +637,13 @@ <h3>Counter<a class="headerlink" href="#counter" title="Permalink to this headli
</div>
</section>
<section id="exercise-4-5">
<h3>Exercise 4.5<a class="headerlink" href="#exercise-4-5" title="Permalink to this headline">#</a></h3>
<h3>Exercise 4.5<a class="headerlink" href="#exercise-4-5" title="Permalink to this heading">#</a></h3>
<p>Use a <code class="docutils literal notranslate"><span class="pre">Counter</span></code> object to count words occurences in the sample text file.</p>
<p>The Counter class is similar to bags or multisets in some Python libraries or other languages. We will see later how to use Counter-like objects in a parallel context.</p>
</section>
</section>
<section id="process-multiple-files">
<h2>Process multiple files<a class="headerlink" href="#process-multiple-files" title="Permalink to this headline">#</a></h2>
<h2>Process multiple files<a class="headerlink" href="#process-multiple-files" title="Permalink to this heading">#</a></h2>
<ul class="simple">
<li><p>Create several files containing <code class="docutils literal notranslate"><span class="pre">lorem</span></code> text named ‘sample01.txt’, ‘sample02.txt’…</p></li>
<li><p>If you process these files you return multiple dictionaries.</p></li>
Expand All @@ -661,13 +662,13 @@ <h2>Process multiple files<a class="headerlink" href="#process-multiple-files" t
</div>
</div>
<section id="exercise-4-6">
<h3>Exercise 4.6<a class="headerlink" href="#exercise-4-6" title="Permalink to this headline">#</a></h3>
<h3>Exercise 4.6<a class="headerlink" href="#exercise-4-6" title="Permalink to this heading">#</a></h3>
<ul class="simple">
<li><p>Write the program that creates files, processes and use <code class="docutils literal notranslate"><span class="pre">itertools.chain</span></code> to get the merged word count dictionary.</p></li>
</ul>
</section>
<section id="exercise-4-7">
<h3>Exercise 4.7<a class="headerlink" href="#exercise-4-7" title="Permalink to this headline">#</a></h3>
<h3>Exercise 4.7<a class="headerlink" href="#exercise-4-7" title="Permalink to this heading">#</a></h3>
<ul class="simple">
<li><p>Create the <code class="docutils literal notranslate"><span class="pre">wordcount</span></code> function in order to accept several files as arguments and
return the result dict.</p></li>
Expand Down

0 comments on commit 1ea4a14

Please sign in to comment.