Reading CSV into Python Pandas? Pass header to specify the row containing column names: No headers at all? Just pass headers=None: Pass a list for multi-indexed column names:
Python Pandas: pivot vs pivot_table? Both reshape data, but: – pivot: one value per cell (errors if duplicates)– pivot_table: aggregates duplicates (mean, sum, etc.) Use pivot for clean data, pivot_table for real-world messiness.
What’s the difference between join and merge in Python Pandas? • join combines based on the indexes. Perfect when both data frames refer to the same person IDs, product names, or dates• merge combines based on *any* two columns — but you must specify which ones.
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!