A file you’re loading into Python Pandas uses weird strings for missing values? Use the na_values parameter in read_* methods:
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!
Break a Python string into a list of strings with str.split: Limit splits with maxsplit: Or split from the right, with a limit:
Joining Python Pandas DataFrames with overlapping columns? You’ll hit: ValueError: columns overlap but no suffix specified Fix with lsuffix and rsuffix: Now the columns are: x_left, x_right, y_left, y_right Problem solved!
Python Pandas gotcha: You can’t join a single column! Why? join() is a data frame method. A single column is a Series. Solution: Use [[ ]] to get a one-column data frame:
I used Python Pandas to total AWS S3 payments. Data was in a CSV file. But numbers in the “Amount” column were written as “USD 12.34”. Here’s what I did:
Python Pandas 3.0 introduces pd.col, which shortens queries: Also:
🎉 Pandas 3 is out! As of last week, saying “pip install pandas” or “uv add pandas” gives you the latest version. What’s new? What has changed? I’ve got a whole YouTube playlist, explaining what you need to know: https://www.youtube.com/playlist?list=PLbFHh-ZjYFwFWHVT0qeg9Jz1TBD0TlJJT