Skip to content

Commit f3b5759

Browse files
committed
Prepare article for publication
1 parent 2d08704 commit f3b5759

3 files changed

+7
-7
lines changed

_posts/2024-02-05-statically-and-dynamically-typed-scripts.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ <h3 id="331b2ed3198f4a59872eb0e9d2f4ebd9">
8686
</p>
8787
<ul>
8888
<li><a href="/2024/02/19/extracting-data-from-a-small-csv-file-with-haskell">Extracting data from a small CSV file with Haskell</a></li>
89-
<li>Extracting data from a small CSV file with Python</li>
89+
<li><a href="/2024/03/18/extracting-data-from-a-small-csv-file-with-python">Extracting data from a small CSV file with Python</a></li>
9090
</ul>
9191
<p>
9292
For this small task, I don't think that there's a clear winner. I still like my Haskell code the best, but I'm sure someone better at Python could write a much cleaner script. I also have to admit that <a href="https://matplotlib.org/">Matplotlib</a> makes it a breeze to produce nice-looking plots with Python, whereas I don't even know where to start with that with Haskell.

_posts/2024-02-19-extracting-data-from-a-small-csv-file-with-haskell.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,6 @@ <h3 id="9b225242b63e4616b25954ad9141e273">
299299
Is it quicker to do it in Python? Not for me, it turns out. It also took me a couple of hours to repeat the exercise in Python.
300300
</p>
301301
<p>
302-
<strong>Next:</strong> Extracting data from a small CSV file with Python.
302+
<strong>Next:</strong> <a href="/2024/03/18/extracting-data-from-a-small-csv-file-with-python">Extracting data from a small CSV file with Python</a>.
303303
</p>
304304
</div>

_posts/2024-02-02-extracting-data-from-a-small-csv-file-with-python.html _posts/2024-03-18-extracting-data-from-a-small-csv-file-with-python.html

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
layout: post
33
title: "Extracting data from a small CSV file with Python"
44
description: "My inept adventures with a dynamically typed language."
5-
date: 2024-02-02 20:29 UTC
5+
date: 2024-03-18 08:36 UTC
66
tags: [Languages]
77
image: "/content/binary/sum-pmf-plot.png"
88
image_alt: "Bar chart of the sum-of-grades PMF."
@@ -14,7 +14,7 @@
1414
<em>{{ page.description }}</em>
1515
</p>
1616
<p>
17-
This article is the third in <a href="">a small series about ad-hoc programming in two languages</a>. In <a href="">the previous article</a> you saw how I originally solved a small data extraction and analysis problem with <a href="https://www.haskell.org/">Haskell</a>, even though it was strongly implied that <a href="https://www.python.org/">Python</a> was the language for the job.
17+
This article is the third in <a href="/2024/02/05/statically-and-dynamically-typed-scripts">a small series about ad-hoc programming in two languages</a>. In <a href="/2024/02/19/extracting-data-from-a-small-csv-file-with-haskell">the previous article</a> you saw how I originally solved a small data extraction and analysis problem with <a href="https://www.haskell.org/">Haskell</a>, even though it was strongly implied that <a href="https://www.python.org/">Python</a> was the language for the job.
1818
</p>
1919
<p>
2020
Months after having solved the problem I'd learned a bit more Python, so I decided to return to it and do it again in Python as an exercise. In this article, I'll briefly describe what I did.
@@ -40,7 +40,7 @@ <h3 id="590b0c98bf064ac0b8893ae41d398daa">
4040
<span style="color:blue;">import</span>&nbsp;matplotlib.pyplot&nbsp;<span style="color:blue;">as</span>&nbsp;plt</pre>
4141
</p>
4242
<p>
43-
In other Python code that I've written, I've been a heavy user of <a href="https://numpy.org/">NumPy</a>, and while I several times added it to my imports, I never needed it for this task.That was a bit surprising, but I've only done Python programming for a year, and I still don't have a good feel for the ecosystem.
43+
In other Python code that I've written, I've been a heavy user of <a href="https://numpy.org/">NumPy</a>, and while I several times added it to my imports, I never needed it for this task. That was a bit surprising, but I've only done Python programming for a year, and I still don't have a good feel for the ecosystem.
4444
</p>
4545
<p>
4646
The above code snippet also demonstrates how easy it is to slice a <em>dataframe</em> into columns: <code>grades</code> contains all the values in the (zero-indexed) second column, and <code>experiences</code> likewise the third column.
@@ -56,7 +56,7 @@ <h3 id="2a5c679e37394960acf5cf283abd41d5">
5656
[('f', 'o'), ('f', 'o'), ('o', 'o')]</pre>
5757
</p>
5858
<p>
59-
Notice that <code>combinations</code> doesn't list <code>('o', 'f')</code>, since (apparently) it doesn't consider ordering important. That's more in line with the <a href="https://en.wikipedia.org/wiki/Binomial_coefficient">binomial coefficient</a>, whereas <a href="">my Haskell code</a> considers a tuple like <code>('f', 'o')</code> to be distinct from <code>('o', 'f')</code>. This is completely consistent with how Haskell works, but means that all the counts I arrived at with Haskell are double what they are in this article. Ultimately, <em>6/1406</em> is equal to <em>3/703</em>, so the probabilities are the same. I'll try to call out this factor-of-two difference whenever it occurs.
59+
Notice that <code>combinations</code> doesn't list <code>('o', 'f')</code>, since (apparently) it doesn't consider ordering important. That's more in line with the <a href="https://en.wikipedia.org/wiki/Binomial_coefficient">binomial coefficient</a>, whereas <a href="/2024/02/19/extracting-data-from-a-small-csv-file-with-haskell">my Haskell code</a> considers a tuple like <code>('f', 'o')</code> to be distinct from <code>('o', 'f')</code>. This is completely consistent with how Haskell works, but means that all the counts I arrived at with Haskell are double what they are in this article. Ultimately, <em>6/1406</em> is equal to <em>3/703</em>, so the probabilities are the same. I'll try to call out this factor-of-two difference whenever it occurs.
6060
</p>
6161
<p>
6262
A <code>Counter</code> object counts the number of occurrences of each value, so reading, picking combinations without replacement and adding them together is just two lines of code, and one more to print them:
@@ -161,7 +161,7 @@ <h3 id="8831d23c67bd48e9b22db86ca3c21bd4">
161161
plt.show()</pre>
162162
</p>
163163
<p>
164-
The bar chart has the same style as before, but obviously displays different data. See the bar chart in the <a href="">previous article</a> for the Excel-based rendition of that data.
164+
The bar chart has the same style as before, but obviously displays different data. See the bar chart in the <a href="/2024/02/19/extracting-data-from-a-small-csv-file-with-haskell">previous article</a> for the Excel-based rendition of that data.
165165
</p>
166166
<h3 id="8d7d707edeba43c59d07b5753a4bdb2d">
167167
Conclusion <a href="#8d7d707edeba43c59d07b5753a4bdb2d">#</a>

0 commit comments

Comments
 (0)