Apply different aggregations to each column when grouping on a Python Pandas data frame with agg and a dict:
Apply multiple aggregations when grouping on a Python Pandas data frame with agg: Grouping on 2+ columns? Each method will be applied to each column:
A file you’re loading into Python Pandas uses weird strings for missing values? Use the na_values parameter in read_* methods:
Unsure how many values you want to unpack in Python? Use * to get a list of flexible length: Note: You can only have one * variable.
Using uv to manage your Python project, and want to increase the version in pyproject.toml? Use “uv version”, specifying what level to increase: uv version –bump=minor uv version –bump=majoruv version –bump=dev Type “uv version –bump” with no value for full docs.
When retrieving a slice with loc in Python Pandas, the end point is included, highly unusual in Python!
Reading a CSV file into a Python Pandas data frame? Speed things up by specifying the PyArrow engine. Data storage isn’t affected. With a 2.2GB file, it took 4s vs. 55s — more than 10x faster!
Does your Python Pandas column contain repeated strings? Turn it into a ‘category’ series (like an enum) to save memory: That’s right — 90% less memory!
Make your Python comprehensions easier to read, write, and debug with multiple lines. # better than:[n**2 for n in range(10) if n%2]
Want to count values in a Python sequence? Use Counter: Bonus: Counter inherits from dict, getting its methods + operators.