Produce a Python blog post with figures

To create a Hugo blog post with Python code and figures, I export an ipython notebook as a .md file. The result is a .zip file containing the .md file and images for the figures. A little modification is needed to get these files just right so that when Hugo builds my website, the post is ready to go with no blank figures. After exporting the jupyter / ipython notebook as .
Read more...

Notes on Python Data Science Handbook

This notebook is on my local filesystem under ~/github/learning-python/notes-PDSH.ipynb and contains notes I made while studying topics from the Python Data Science Handbook by Jake Vanderplas. His Github repo of the book is here. I forked the repo, and that clone is located on my local filesystem at ~/github/jakevdp_PythonDataScienceHandbook Chapter 3: Data Manipulation with Pandas (p. 97) Introducing Pandas objects (p. 98) The Pandas Index object (p. 105) Index objects are immutable.
Read more...

Regression in Python

Linear and Polynomial Regression Here’s some cool initial code from page 378 (under “Derived Features” in the section on Feature Engineering) in the Python Data Science Handbook (PDSH). This code will allow me to quickly fit a linear and polynomial regression to very simple data. My comments are marked something like ### GJL:: % matplotlib inline import numpy as np import matplotlib.pyplot as plt x = np.array([1,2,3,4,5]) y = np.
Read more...

Python: single underscores vs. double underscores

This Youtube video is a really great 6 minute demonstration of the distinction between _ and __. I’ll embed the linked video at the end of this post. One of the top comments on that video says For C++ people, foo is public, _bar is protected, and __baz is private. Here’s a simple class, with an initializer implemented, including the three variables foo, _bar, and __baz. class Test: def __init__(self): self.
Read more...

Blogging with runnable Python in Rmarkdown files

I wondered if I could blog with runnable Python code chunks if I’m creating my Hugo content with .Rmarkdown files. It looks like I can with the reticulate package; see the vignette here. install.packages('reticulate', repos="https://cloud.r-project.org") library(reticulate) I believe this allows you to actually run Python. Alternatively, if you just want to display Python code, just use a code fence, i.e. the Github-style code block that’s 3 backticks, new line, code, then three closing backticks on a new line, like so:
Read more...