If you want to get better at Pandas, the hard part isn’t finding tutorials. It’s finding problems worth solving. Most exercises hand you a tidy little table of five rows and ask you to sum a column โ which teaches you the syntax, but nothing about the job. For the last 3.5 years, I’ve written…
Over my 30+ years teaching Python, I’ve included practice exercises in all of my courses. And when I started to teach Git and Pandas, I made sure to include practice exercises there, too. That’s because there’s no learning without practice. At least, there’s no effective learning. Frustration isn’t fun, but it’s a necessary part of…
๐ 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
Know Python Pandas series methods? You already know data frame methods! Same methods, applied column-wise!
Reading a multi-sheet Excel file into Python Pandas? Ask for a specific sheet by name or index: Get a dict of data frames with specific sheets:
How much memory does a text column in your Python Pandas data frame use? Check: But this is likely a huge underestimate! It sums the pointer sizes, not the string sizes. Instead, say: Or:
Want to turn an online CSV file into a Python Pandas data frame? Just pass a URL to read_csv: Options such as usecols and index_col work! This works on all read_* methods, including read_excel, read_json, and read_parquet.
After plotting a Python Pandas data frame in Jupyter, how do you save it to a file?
If your Python Pandas dataframe has a datetime index, use a slice to retrieve rows in a certain time period: But if the rows are unsorted? You get a KeyError. Solution:
Retrieve rows of a Python Pandas data frame with the 6 largest values of column x: Even better: Why is it better? On a 3m row, 680 MB data frame, sort/tail took 622 ms. nlargest? Only 84 ms โ 7x faster!