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…
Want to check whether a Python Pandas string series only contains digits? Use str.isdigit: This returns a boolean series, with df’s index. You can then convert the digit-containing strings to integers:
Want to retrieve a slice from a string column in your Python Pandas data frame? Use .str.slice:
Want to retrieve from a string column in your Python Pandas data frame? Use .str.get: But wait: You can use [], in place of .get: