Python Jupyter memory quirk: Deleting variables doesn’t always free memory! Use df.head() instead of df to keep big values out of Jupyter’s Out dict.
Playing NYT Spelling Bee? Use Python to see if your word only uses allowed letters (ignoring length + center): With sets, <= checks “subset or equal”:
Create a Python dict with keys a/b/c and values 0: But don’t do this, since the value will be shared and mutable: {‘a’: [‘x’, ‘y’], ‘b’: [‘x’, ‘y’], ‘c’: [‘x’, ‘y’]} 🤯
“round” rounds Python numbers: Remember, .5 goes to the nearest *even* value:
How can you tell if a Python datetime is a weekend (i.e., Saturday or Sunday)? Invoke weekday(). It returns an int; Mon is 0, Sat is 5 and Sun is 6. So:
Consider this Python: Surprised? That’s because “is” is the wrong comparison: • == asks: are these the same value?• is asks: are these the same object? You almost never care about question #2. And so, should rarely use “is”.
Want to make Python numbers more readable? Use _ between digits (not at the start or end):
Can you believe that 2025 is almost over? It was full of big events for me, and yet it also whizzed past at breakneck speed. And so, before we start 2026, I want to share a whole bunch of updates on what I’ve done over the last 12 months — and where I plan to…