There are more python libraries than you can shake a stick at, but here are a handful that don’t get much love and may save you some brain power, compute time or both.
Fire is a library which turns your normal python functions into command-line utilities without requiring more than a couple of additional lines of copy-and-paste code. Being able to immediately access your functions from the command line is amazingly helpful when you’re making quick and dirty utilities and saves needing to reach for the nuclear approach of using getopt.
Pyodide provides a way of running python in your web browser. “So what?” you may ask, I’ve already got jupyter notebooks, colab etc. Pyodide is different, it runs SOLELY in your browser, there’s no back end server. Not just that, it runs python and the huge suites of the C libraries that actually make python useful (think NumPy, Pandas, Matplotlib, SciPy, scikit-learn etc.) by converting them into webkit/javascript/html so that your code runs completely within in the browser and has access to the browser’s APIs.
Modin is an embarrassment* of pandas and they’re on steroids. Pandas can only utilise a single CPU core, no matter how many are available; modin on the other hand will automatically parallelise across as many as you’ve got. When using modin, often the biggest change you’ll need to make to your code is:
#import pandas as pd
import modin.pandas as pd
Whilst modin doesn’t re-implement everything which pandas can do, the authors say it covers all of the most commonly used functions such as pd.read_csv with significant speed-ups and >90% of all the bells and whistles found in pd.DataFrame.
* It would appear the collective noun for pandas is an embarrassment.
Openpyxl allows you to read and write Microsoft Excel xlsx workbooks. Sooner or later someone’s going to take your carefully curated output and cram it into Excel, or hand you an Excel spreadsheet full of raw data (with or without formatting errors). Excel isn’t going away and you’re not going to get away from it, so why not grudgingly embrace it like a slightly racist elderly relative?
Colorama allows you to trivially add a splash of colour to your terminal output. Whilst you could of course do this by printing ANSI escape sequences you’ve got to admit they’re no where near as user friendly as the Colorama version.
#Colorama from colorama import Fore, Back, Style print(Fore.RED + 'some red text') #ANSI version print("\u001b[31msome red text\033[0m")
Turtle is everything which matplotlib isn’t. If you don’t want to spend your time having a turtle crawl about your screen drawing your graphs, you’re just wrong. The python Turtle can also draw geometric figures: