Skip to content

Commit

Permalink
deploy: 37e4aeb
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanTodoran committed Oct 9, 2023
1 parent 7148440 commit 7b8cc65
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 34 deletions.
72 changes: 45 additions & 27 deletions Chapter2-DataManipulation/2.4_pandas_rendered.html
Original file line number Diff line number Diff line change
Expand Up @@ -599,18 +599,23 @@ <h1 class="site-logo" id="site-title">ML Geo Curriculum</h1>
</a>
</li>
<li class="toc-h1 nav-item toc-entry">
<a class="reference internal nav-link" href="#the-basics-of-pandas">
The Basics of Pandas
</a>
</li>
<li class="toc-h1 nav-item toc-entry">
<a class="reference internal nav-link" href="#reading-a-dataframe-from-a-csv-file">
Reading a DataFrame from a CSV file
<a class="reference internal nav-link" href="#pandas-fundamentals">
1. Pandas Fundamentals
</a>
<ul class="visible nav section-nav flex-column">
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#simple-python-functions">
Simple Python Functions
<a class="reference internal nav-link" href="#basics">
1.1 Basics
</a>
</li>
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#reading-a-dataframe-from-a-csv-file">
1.3 Reading a DataFrame from a CSV file
</a>
</li>
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#basic-python-functions">
1.3 Basic Python Functions
</a>
</li>
<li class="toc-h2 nav-item toc-entry">
Expand Down Expand Up @@ -660,18 +665,23 @@ <h2> Contents </h2>
</a>
</li>
<li class="toc-h1 nav-item toc-entry">
<a class="reference internal nav-link" href="#the-basics-of-pandas">
The Basics of Pandas
</a>
</li>
<li class="toc-h1 nav-item toc-entry">
<a class="reference internal nav-link" href="#reading-a-dataframe-from-a-csv-file">
Reading a DataFrame from a CSV file
<a class="reference internal nav-link" href="#pandas-fundamentals">
1. Pandas Fundamentals
</a>
<ul class="visible nav section-nav flex-column">
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#simple-python-functions">
Simple Python Functions
<a class="reference internal nav-link" href="#basics">
1.1 Basics
</a>
</li>
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#reading-a-dataframe-from-a-csv-file">
1.3 Reading a DataFrame from a CSV file
</a>
</li>
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#basic-python-functions">
1.3 Basic Python Functions
</a>
</li>
<li class="toc-h2 nav-item toc-entry">
Expand Down Expand Up @@ -708,7 +718,7 @@ <h2> Contents </h2>

<section class="tex2jax_ignore mathjax_ignore" id="pandas-basic-mapping">
<h1>2.4 Pandas, Basic Mapping<a class="headerlink" href="#pandas-basic-mapping" title="Permalink to this headline">#</a></h1>
<p>This section aims to provide new skills in python to handle structured “table” data.</p>
<p>This section aims to provide new skills in python to handle structured, tabular data.</p>
<p>Learning outcome:</p>
<ul class="simple">
<li><p>Manipulation of data frames (describing, filtering, …)</p></li>
Expand All @@ -718,6 +728,7 @@ <h1>2.4 Pandas, Basic Mapping<a class="headerlink" href="#pandas-basic-mapping"
<li><p>Introduction to Plotly</p></li>
<li><p>Introduction to CSV &amp; Parquet</p></li>
</ul>
<p>This tutorial can be offered in a 2-hour course. Sections are labeled as Level 1, 2, 3 in Section 1, 2, 3, and instructors may choose to leave higher levels for asynchronous, self-guided learning.</p>
<p>We will work on several structured data sets: sensor metadata, seismic data product (earthquake catalog).</p>
<p>First, we import all the modules we need:</p>
<div class="cell docutils container">
Expand All @@ -740,8 +751,10 @@ <h1>2.4 Pandas, Basic Mapping<a class="headerlink" href="#pandas-basic-mapping"
</div>
</div>
</section>
<section class="tex2jax_ignore mathjax_ignore" id="the-basics-of-pandas">
<h1>The Basics of Pandas<a class="headerlink" href="#the-basics-of-pandas" title="Permalink to this headline">#</a></h1>
<section class="tex2jax_ignore mathjax_ignore" id="pandas-fundamentals">
<h1>1. Pandas Fundamentals<a class="headerlink" href="#pandas-fundamentals" title="Permalink to this headline">#</a></h1>
<section id="basics">
<h2>1.1 Basics<a class="headerlink" href="#basics" title="Permalink to this headline">#</a></h2>
<p>Pandas are composed of <code class="docutils literal notranslate"><span class="pre">Series</span></code> and <code class="docutils literal notranslate"><span class="pre">DataFrame</span></code>. <code class="docutils literal notranslate"><span class="pre">Series</span></code> are columns with attributes or keys. The <code class="docutils literal notranslate"><span class="pre">DataFrame</span></code> is a multi-dimensional table made up of <code class="docutils literal notranslate"><span class="pre">Series</span></code>.</p>
<p>We can create a DataFrame composed of series from scratch using Python dictionary:</p>
<div class="cell docutils container">
Expand Down Expand Up @@ -813,8 +826,8 @@ <h1>The Basics of Pandas<a class="headerlink" href="#the-basics-of-pandas" title
</div>
</div>
</section>
<section class="tex2jax_ignore mathjax_ignore" id="reading-a-dataframe-from-a-csv-file">
<h1>Reading a DataFrame from a CSV file<a class="headerlink" href="#reading-a-dataframe-from-a-csv-file" title="Permalink to this headline">#</a></h1>
<section id="reading-a-dataframe-from-a-csv-file">
<h2>1.3 Reading a DataFrame from a CSV file<a class="headerlink" href="#reading-a-dataframe-from-a-csv-file" title="Permalink to this headline">#</a></h2>
<p>We can read a pandas directly from a standard file. Here you will read a catalog of earthquakes.</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
Expand Down Expand Up @@ -1054,8 +1067,9 @@ <h1>Reading a DataFrame from a CSV file<a class="headerlink" href="#reading-a-da
</div>
</div>
</div>
<section id="simple-python-functions">
<h2>Simple Python Functions<a class="headerlink" href="#simple-python-functions" title="Permalink to this headline">#</a></h2>
</section>
<section id="basic-python-functions">
<h2>1.3 Basic Python Functions<a class="headerlink" href="#basic-python-functions" title="Permalink to this headline">#</a></h2>
<p>We will now practice how to modify the content of the DataFrame using functions. We will take the example where we want to change the depth values from meters to kilometers. First we can define this operation as a function</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
Expand Down Expand Up @@ -1190,18 +1204,22 @@ <h2>Simple Python Functions<a class="headerlink" href="#simple-python-functions"
</div>
</div>
</div>
<p>Instead, you could overwrite <code class="docutils literal notranslate"><span class="pre">quake.depth=X</span></code>. Try two approaches but just do it once!</p>
<p>Instead, you could overwrite <code class="docutils literal notranslate"><span class="pre">quake.depth=X</span></code>. Try two approaches but just do it once! You can use python functions <code class="docutils literal notranslate"><span class="pre">map</span></code> (a function to apply functions that is generic to Python) and <code class="docutils literal notranslate"><span class="pre">apply</span></code> (a function to apply functions that is specific to Pandas).</p>
<div class="admonition-student-response-section admonition">
<p class="admonition-title">Student response section</p>
<p>This section is left for the student to complete.</p>
</div>
<p>Try <code class="docutils literal notranslate"><span class="pre">map</span></code> to apply a <code class="docutils literal notranslate"><span class="pre">lambda</span></code> function that rescale depth from meters to kilometers.</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># implement answer here</span>
</pre></div>
</div>
</div>
</div>
<p>Discuss in class: What happened to the depth field?</p>
<p>What happened to the original data frame?</p>
<p>Try <code class="docutils literal notranslate"><span class="pre">apply</span></code> to apply a <code class="docutils literal notranslate"><span class="pre">lambda</span></code> function that rescale depth from meters to kilometers.</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># or like this</span>
Expand All @@ -1222,7 +1240,7 @@ <h2>Simple Python Functions<a class="headerlink" href="#simple-python-functions"
</div>
</div>
</div>
<p>You can use the interactive plotting package Plotly. First we will show a histogram of the event depth using the function <code class="docutils literal notranslate"><span class="pre">histogram</span></code></p>
<p>You can use the interactive plotting package Plotly. First we will show a histogram of the event depth using the function <code class="docutils literal notranslate"><span class="pre">histogram</span></code>.</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">fig</span> <span class="o">=</span> <span class="n">px</span><span class="o">.</span><span class="n">histogram</span><span class="p">(</span><span class="n">quake</span><span class="p">,</span> <span class="c1">#specify what dataframe to use</span>
Expand Down
42 changes: 36 additions & 6 deletions _sources/Chapter2-DataManipulation/2.4_pandas_rendered.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"source": [
"# 2.4 Pandas, Basic Mapping\n",
"\n",
"This section aims to provide new skills in python to handle structured \"table\" data. \n",
"This section aims to provide new skills in python to handle structured, tabular data. \n",
"\n",
"Learning outcome:\n",
"- Manipulation of data frames (describing, filtering, ...) \n",
Expand All @@ -17,6 +17,8 @@
"- Introduction to Plotly\n",
"- Introduction to CSV & Parquet\n",
"\n",
"This tutorial can be offered in a 2-hour course. Sections are labeled as Level 1, 2, 3 in Section 1, 2, 3, and instructors may choose to leave higher levels for asynchronous, self-guided learning.\n",
"\n",
"\n",
"We will work on several structured data sets: sensor metadata, seismic data product (earthquake catalog).\n",
"\n",
Expand Down Expand Up @@ -50,7 +52,9 @@
"id": "3f1829a3",
"metadata": {},
"source": [
"# The Basics of Pandas \n",
"# 1. Pandas Fundamentals\n",
"\n",
"## 1.1 Basics\n",
"\n",
"Pandas are composed of ``Series`` and ``DataFrame``. ``Series`` are columns with attributes or keys. The ``DataFrame`` is a multi-dimensional table made up of ``Series``.\n",
"\n",
Expand Down Expand Up @@ -180,7 +184,7 @@
"id": "9fca0cf5",
"metadata": {},
"source": [
"# Reading a DataFrame from a CSV file\n",
"## 1.3 Reading a DataFrame from a CSV file\n",
"\n",
"We can read a pandas directly from a standard file. Here you will read a catalog of earthquakes."
]
Expand Down Expand Up @@ -523,7 +527,7 @@
"id": "591f8d33",
"metadata": {},
"source": [
"## Simple Python Functions\n",
"## 1.3 Basic Python Functions\n",
"We will now practice how to modify the content of the DataFrame using functions. We will take the example where we want to change the depth values from meters to kilometers. First we can define this operation as a function"
]
},
Expand Down Expand Up @@ -749,7 +753,7 @@
"id": "6347a1ec",
"metadata": {},
"source": [
"Instead, you could overwrite ``quake.depth=X``. Try two approaches but just do it once!"
"Instead, you could overwrite ``quake.depth=X``. Try two approaches but just do it once! You can use python functions ``map`` (a function to apply functions that is generic to Python) and ``apply`` (a function to apply functions that is specific to Pandas)."
]
},
{
Expand All @@ -762,6 +766,14 @@
"```"
]
},
{
"cell_type": "markdown",
"id": "0d45bc9b",
"metadata": {},
"source": [
"Try ``map`` to apply a ``lambda`` function that rescale depth from meters to kilometers."
]
},
{
"cell_type": "code",
"execution_count": 19,
Expand All @@ -772,6 +784,24 @@
"# implement answer here"
]
},
{
"cell_type": "markdown",
"id": "9b11b4cb",
"metadata": {},
"source": [
"Discuss in class: What happened to the depth field?\n",
"\n",
"What happened to the original data frame?"
]
},
{
"cell_type": "markdown",
"id": "a520ada6",
"metadata": {},
"source": [
"Try ``apply`` to apply a ``lambda`` function that rescale depth from meters to kilometers."
]
},
{
"cell_type": "code",
"execution_count": 20,
Expand Down Expand Up @@ -816,7 +846,7 @@
"id": "8bb58e3c",
"metadata": {},
"source": [
"You can use the interactive plotting package Plotly. First we will show a histogram of the event depth using the function ``histogram``"
"You can use the interactive plotting package Plotly. First we will show a histogram of the event depth using the function ``histogram``."
]
},
{
Expand Down
4 changes: 4 additions & 0 deletions _sources/about_this_book/about_this_book.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ By the end of the quarter, the students should be able to:
- Understand at least qualitatively how some of the advanced techniques (Fourier and wavelet transform, principal component analysis, …) manipulate and transform the data to interpret the output.


# Tiered Level Learning
Because students do not need to be experts on all materials covered in this course, we propose a three-level material: **Beginning (Level 1)**, **Intermediate (Level 2)**, **Advanced (Level 3)**, and tag these levels throughout the book.


**Prerequisites**: MATH 207 and MATH 208, or MATH 307 or 308, or AMATH 351 or 352, CS160 or CS163, or permission from the instructor.

**Recommended**: Knowledge in Matlab or python, AMATH301, 100- or 200-level courses in the Earth Sciences. Refreshers in computing skills will be provided.
Expand Down
14 changes: 14 additions & 0 deletions about_this_book/about_this_book.html
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,11 @@ <h1 class="site-logo" id="site-title">ML Geo Curriculum</h1>
Learning objectives
</a>
</li>
<li class="toc-h1 nav-item toc-entry">
<a class="reference internal nav-link" href="#tiered-level-learning">
Tiered Level Learning
</a>
</li>
<li class="toc-h1 nav-item toc-entry">
<a class="reference internal nav-link" href="#syllabus">
Syllabus
Expand Down Expand Up @@ -644,6 +649,11 @@ <h2> Contents </h2>
Learning objectives
</a>
</li>
<li class="toc-h1 nav-item toc-entry">
<a class="reference internal nav-link" href="#tiered-level-learning">
Tiered Level Learning
</a>
</li>
<li class="toc-h1 nav-item toc-entry">
<a class="reference internal nav-link" href="#syllabus">
Syllabus
Expand Down Expand Up @@ -707,6 +717,10 @@ <h1>Learning objectives<a class="headerlink" href="#learning-objectives" title="
<li><p>Describe the canonical examples in a breadth of disciplines in geoscience.</p></li>
<li><p>Understand at least qualitatively how some of the advanced techniques (Fourier and wavelet transform, principal component analysis, …) manipulate and transform the data to interpret the output.</p></li>
</ul>
</section>
<section class="tex2jax_ignore mathjax_ignore" id="tiered-level-learning">
<h1>Tiered Level Learning<a class="headerlink" href="#tiered-level-learning" title="Permalink to this headline">#</a></h1>
<p>Because students do not need to be experts on all materials covered in this course, we propose a three-level material: <strong>Beginning (Level 1)</strong>, <strong>Intermediate (Level 2)</strong>, <strong>Advanced (Level 3)</strong>, and tag these levels throughout the book.</p>
<p><strong>Prerequisites</strong>: MATH 207 and MATH 208, or MATH 307 or 308, or AMATH 351 or 352, CS160 or CS163, or permission from the instructor.</p>
<p><strong>Recommended</strong>: Knowledge in Matlab or python, AMATH301, 100- or 200-level courses in the Earth Sciences. Refreshers in computing skills will be provided.</p>
</section>
Expand Down
2 changes: 1 addition & 1 deletion searchindex.js

Large diffs are not rendered by default.

0 comments on commit 7b8cc65

Please sign in to comment.