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…
Once you import a Python module, a second import won’t reload it. That’s usually good. But what if you want to? (Common in development and debugging.) This forces the reload.
You import a Python module with the variable you’ll define, not a filename. “import mymod” tells Python to find mymod.py in each dir in sys.path. The first directory is ” (the empty string) — i.e., the directory where the program is running (i.e., not where it was defined).
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…
I just got back from PyCon US. It was delightful; I saw old friends, met new ones, gave a tutorial on decorators, and spoke at the education summit. I’m a PyCon US sponsor, which means that I also had a booth, giving out T-shirts, books, stickers, and flyers about the LernerPython platform. Of course, the…
If you’re like me, then you’ve lately been exploring agentic coding, having AI write code on your behalf. What will be the impact on our work developing software? On hiring? On training? From what I can tell, the question isn’t whether we’ll be using agentic coding, but how we do so. Knowing how AI writes…
TL;DR: If you teach Python, then you should check out course-setup (https://pypi.org/project/course-setup/) at PyPI! I’ve been teaching Python and Pandas for many years. And while I started my teaching career like many other instructors, with slides, I quickly discovered that it was better for my students — and for me! — to replace them with…
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: