seaborn is a Python graphing library which interacts incredibly well with pandas. Yes, pandas does have its own plotting functions accessible from df.plot, which are particularly easy to build and (quite conveniently) don’t require another external library. I’ve fond pandas‘ plots particularly useful to do quick checks and calculations while doing some other aspect of…
Fixing Healthcare Text for NLP: Spell Correction and Word Segmentation
Healthcare text can be challenging to work with. The transformations, simplifications, and shortcuts taken to store this data for secondary use (e.g., research) result in major problems for ultimate use. These upstream failures might strip spaces (thereby causing run-together words), remove other formatting characters (e.g., newlines and tabs), and combine what were once pretty-looking tables…
Logging Function Parameters with `loguru`
Log files can often be useful sources of historical information about how programs run. I have found them sitting next to datasets and used them to get more information on the provenance of the dataset. Perhaps I could add a function that would log all of the parameters that were run? Sure, a configuration file…
`argparse`: Optional Argument and Flag?
I was modifying an program recently which uses argparse to collect command line options in order to add an option to enable a ‘testrun’. The script begins by copying a large cohort to a server before taking several steps manipulating it. When I ran it with a new configuration file, there was a misconfigured flag,…
Extracting a Table from PDF with Tabula
An email arrives with an attached PDF and a request that some multi-page embedded table be extracted into Excel. For example, the following presents a short snippet: How would you handle it? Sure, this table is relatively trivial to manually extract, but imagine a PDF continuing for several pages. Fortunately, there are several Python libraries…
Extracting a Table from a PDF with Camelot
An email arrives with an attached PDF and a request that some multi-page embedded table be extracted into Excel. For example, the following presents a short snippet: How would you handle it? Sure, this table is relatively trivial to manually extract, but imagine a PDF continuing for several pages. Fortunately, there are several Python libraries…
Running `prodigy` with Encryption and Authentication
I have a prodigy task ready for internal (not internet-wide) review and have it running on a server with the host set to 0.0.0.0, but want to keep the contents secure so that only the specified reviewer can see and interact with the review process. For context, let’s suppose that I’m working on a Windows…
Creating a Self-Signed Cert
One component of the security of a website is to ensure that client and server are communicating with each other without anyone intercepting the traffic. This is the reason for the ‘s’ tacked onto the http of your URL. On the great wide web, there are a number of certificate authorities, but my intranet lacks…
Sharing `click` Options
One nuisance with building command line options in argparse, click, or any other system is duplicates in the parameter list. When using argparse, I would call various functions to add a set of arguments to my ArgumentParser (e.g., for shared output parameters/configuration): Treat the above (and below) as pseudocode, but hopefully they gets the idea…
A Quickety `click` Tutorial
I’ve always used argparse. I’ve tried a few others, but it’s hard to be beat a built-in argument parser with power and flexibility of argparse. Recently, however, I’ve found click appearing increasingly in my requirements.txt and pyproject.toml. While I have not explored the depths of click (most of my use cases don’t involve a high…