Reuven M. Lerner's Avatar

Reuven M. Lerner

@lernerpython.com.bsky.social

Helping you become more confident with Python and Pandas since 1995. • Courses: LernerPython.com • Newsletters: BetterDevelopersWeekly.com • BambooWeekly.com • Books: PythonWorkout.com • PandasWorkout.com • Videos: YouTube.com/reuvenlerner

3,276 Followers  |  585 Following  |  410 Posts  |  Joined: 30.07.2023  |  2.0075

Latest posts by lernerpython.com on Bluesky

Post image

Last week's US jobs report reduced previous estimates, leading to the firing of the head statistician.

Today's Bamboo Weekly examines the BLS data, calculating these changes ourselves with #Python #Pandas.

Improve your data skills every Wednesday: bambooweekly.com

06.08.2025 15:00 — 👍 0    🔁 0    💬 0    📌 0
Commas in Python integer input and output
YouTube video by Python and Pandas with Reuven Lerner Commas in Python integer input and output

Do you usually separate groups of digits with commas? Do that in #Python, and you'll have trouble.

In my latest video, I show you how to separate digits in Python, and then how to display numbers separated by commas, too.

Check it out: youtu.be/hhgg9SFyQZs?...

05.08.2025 12:19 — 👍 1    🔁 0    💬 0    📌 0
Home Page | Chicagoland

IIBA Chicagoland Chapter
Showcasing the Powers of Jupyter -
@lernerpython.com Reuven Lerner
Join us on Zoom this Wed!
Aug 6, 6:00-7:30pm CT
Cost: Free

chicago.iiba.org/.../showcasi...

#Python #Jupyter #Pandas #DataFormats #Export #Import #BusinessAnalysis

03.08.2025 14:34 — 👍 2    🔁 1    💬 0    📌 1
Preview
Bamboo Weekly Level up your data-analysis skills with Python and Pandas, solving problems with real-world data sets based on current events.

Tom Lehrer passed away this week, so the latest Bamboo Weekly is about analyzing his lyrics with #Python #Pandas:

• Create a data frame from text files
• Using .str methods
• Extract text with regex

Improve your data-analysis skills each Wednesday: bambooweekly.com

30.07.2025 17:35 — 👍 2    🔁 0    💬 0    📌 0

Oh, and I had *completely* forgotten that we met when you took my class with Cisco! I figured that we had met at PyCon US a number of years ago...

30.07.2025 04:46 — 👍 1    🔁 0    💬 0    📌 0
Python immutable vs. constants — how are they different?
YouTube video by Python and Pandas with Reuven Lerner Python immutable vs. constants — how are they different?

Yeah, I wouldn't phrase it this way. I think you're somewhat confusing the idea of a constant (where a variable's reference to a value is fixed and unchangeable) and immutable (where a value cannot change).

Maybe this will help: www.youtube.com/watch?v=XPrZ...

30.07.2025 04:43 — 👍 0    🔁 0    💬 2    📌 0

True -- we talk about mutable vs. immutable as if they were strictly defined categories, and that everything falls into one or the other. But aside from some builtin data structures, nothing in Python is truly immutable. We can create almost-immutable values, but it's never 100%.

30.07.2025 04:40 — 👍 1    🔁 0    💬 0    📌 0

Fair enough!

That said, I always love showing this to people:

t = ([10, 20, 30], [40, 50, 60])
t += [35]

which has more to do with magic methods than with immutability, but I'll do anything to shock my students. :-)

29.07.2025 18:55 — 👍 2    🔁 0    💬 2    📌 0

No! You can think of the tuple as containing a fixed number of reference (pointers, more or less) to another object. The references cannot change -- you can't add new ones, remove existing ones, or modify existing ones -- but the objects to which they refer *can* change.

29.07.2025 18:40 — 👍 0    🔁 0    💬 1    📌 0
What does "mutable" mean in Python?
YouTube video by Python and Pandas with Reuven Lerner What does "mutable" mean in Python?

#Python people talk a lot about "mutable" and "immutable" data.

What does that mean, though?

In my latest video, I break it down, showing you what it means for a data structure (e.g., a list or dict) to be mutable.

youtu.be/qfQBMq4IH1s?...

29.07.2025 16:52 — 👍 3    🔁 2    💬 1    📌 0
When Python variable assignment goes wrong -- issues with x=y=z
YouTube video by Python and Pandas with Reuven Lerner When Python variable assignment goes wrong -- issues with x=y=z

Ever use the x=y=z syntax in #Python, assigning multiple variables at the same time?

Ever discover it didn't quite work right?

In my latest video, I show you what's happening behind the scenes, and where this syntax can bite you: youtu.be/rm_T1x3VnMU?...

28.07.2025 17:10 — 👍 1    🔁 0    💬 0    📌 0
How to conference I love conferences. I enjoy everything about them -- the nonstop stream of learning, the chance to see old friends and meet new ones, and just generally to be around a lot of interesting, smart,

I'm now an old hand at #Python conferences, and feel very comfortable there. But for many, it can be overwhelming and daunting.

Here are some tips for anyone attending a conference for the first time, who wants to get the most out of it: lerner.co.il/2025/07/27/h...

27.07.2025 11:22 — 👍 3    🔁 1    💬 0    📌 0
Post image

It's summer in much of the world, and this summer is *hot*!

In the latest Bamboo Weekly, I pose six questions based on European climate data. But we also explore xarray, PyArrow, pivot tables, plotting, and memory optimization.

Level up your #Python #Pandas every Wednesday: bambooweekly.com !

24.07.2025 00:02 — 👍 0    🔁 0    💬 0    📌 0
5 Common Pandas mistakes (and how to fix them!)
YouTube video by Python and Pandas with Reuven Lerner 5 Common Pandas mistakes (and how to fix them!)

Using #Python #Pandas? I've been teaching it for many years, and I've seen lots of people make the same mistakes.

In my latest video, I review (and explain) those mistakes, and how to correct them: www.youtube.com/watch?v=ctpl...

23.07.2025 09:39 — 👍 2    🔁 0    💬 0    📌 0
Understanding Python list comprehensions
YouTube video by Python and Pandas with Reuven Lerner Understanding Python list comprehensions

Confused by #Python comprehensions? You're not alone! Lots of people find the syntax a bit mystifying.

In this video, I break down what comprehensions do, how to use them, and how to write them so that you can better understand what's going on: www.youtube.com/watch?v=EqAE...

23.07.2025 08:41 — 👍 1    🔁 2    💬 0    📌 0
Preview
What does = do? (Talk from Euro Python 2025) We use assignment all the time in Python. But what really happens when we use an = in our code? The answer is: It depends. In this talk, I'll explore wh…

I had a great time presenting, "What does = do?" at @europython.eu earlier today in Prague.

I've uploaded the slides, if you want to take a look:

speakerdeck.com/reuven/what-...

18.07.2025 13:51 — 👍 3    🔁 0    💬 0    📌 0
Post image

Delightfully emcouraging keynote from @savannah.dev at @europython.eu about how everyone can, and should, contribute to Python... And that everyone does something different, in their own way, which is a good thing.

A great way to start the conference!

16.07.2025 08:16 — 👍 8    🔁 1    💬 1    📌 0
Replace "for" loops with windowing methods in Pandas
YouTube video by Python and Pandas with Reuven Lerner Replace "for" loops with windowing methods in Pandas

Some #Python #Pandas calculations seem like they need a "for" loop:

• By how much (amount or %) does each row differ from the previous one?
• Aggregate over every group of 5 consecutive rows

You don't need a loop. You need a Pandas windowing methods.

Learn more: www.youtube.com/watch?v=BzB0...

14.07.2025 14:34 — 👍 0    🔁 0    💬 0    📌 0
How to take int input in Python — safely and correctly
YouTube video by Python and Pandas with Reuven Lerner How to take int input in Python — safely and correctly

Trying to get integer input from a user in #Python? You can, of course, run int() on the result from input(). But what if the user enters non-numeric data?

In my latest video, I show you two ways to handle this, and why exception handling is the more "Pythonic": www.youtube.com/watch?v=nW-7...

14.07.2025 05:26 — 👍 2    🔁 0    💬 0    📌 0
Post image

How many Americans bought electric vehicles (EVs) in the last decade?

In the latest Bamboo Weekly, I pose six problems on this topic, using data from the Department of Transportation.

Level up your #Python #Pandas skills every Wednesday: bambooweekly.com

11.07.2025 06:02 — 👍 2    🔁 0    💬 0    📌 0
Pandas time series superpowers: Why datetime indexes matter
YouTube video by Python and Pandas with Reuven Lerner Pandas time series superpowers: Why datetime indexes matter

Q: If we can retrieve from a #Python #Pandas datetime column, then what's the advantage of a time series?

A: You can do three things that would otherwise be annoying or impossible:

1. Wildcard date retrieval
2. Date slices
3. Resampling

Take a look: youtu.be/M4qhlzzrCXg

10.07.2025 14:13 — 👍 2    🔁 0    💬 0    📌 0
Making a multi-index from an anonymous column
YouTube video by Python and Pandas with Reuven Lerner Making a multi-index from an anonymous column

Reading an Excel file into a Pandas data frame isn't hard.

But what if you want 2 columns to be a multi-index... and one is unnamed?

In my latest video, I show you how to create a multi-index in such cases. *PLUS* we talk about assign, transpose, and pipe.

Check it out: youtu.be/wf_nbP-S5rk?...

10.07.2025 13:24 — 👍 0    🔁 0    💬 0    📌 0

A lot of #Python developers think that "with" is about opening files. And it's certainly used there! But it's much more than that.

In this video, I explain what "with" does, the context-manager protocol, and how to make your own objects behave inside of a "with" block:

youtu.be/i3iqByWM7icl...

10.07.2025 04:49 — 👍 3    🔁 1    💬 0    📌 0
Load your data with the right index in Pandas (read_csv tips)
YouTube video by Python and Pandas with Reuven Lerner Load your data with the right index in Pandas (read_csv tips)

Want to replace your #Python #Pandas data frame's default index with one of its columns? Use set_index, of course.

But it's faster and easier to pass index_col to read_csv, letting you set indexes, multi-indexes, and time-series indexes.

Watch and learn: youtu.be/kzUyeMcMQLw?...

09.07.2025 11:41 — 👍 2    🔁 0    💬 0    📌 0
Why Pandas string methods are slower than you think
YouTube video by Python and Pandas with Reuven Lerner Why Pandas string methods are slower than you think

You've been told not to use "for" loops in #Python #Pandas. Or to use "apply". So you use ".str" instead.

But sometimes "str" is slower than "apply". How can this be?

In my latest video, I explain why — and demonstrate PyArrow strings, which run 20x faster.

Watch here: youtu.be/Ovz8F464uo0?...

08.07.2025 13:30 — 👍 1    🔁 0    💬 0    📌 0

I wonder if individuals and small teams will see a big boost, but large teams won't - because the bottleneck on a team is often communication.

Of course, if an AI tool lets you replace a big team with a small one, then your overall deployment rate won't change, but per person LOC will.

08.07.2025 08:26 — 👍 4    🔁 0    💬 0    📌 0

I've been in business for 30 years. I can't imagine sending such a letter to any of my colleagues, suppliers, clients, employees... anyone at all, actually, and expect to be taken seriously.

And yet... that's the current reality.

07.07.2025 16:42 — 👍 45    🔁 1    💬 0    📌 0
Merging in Pandas? Here's why you’re getting _x and _y
YouTube video by Python and Pandas with Reuven Lerner Merging in Pandas? Here's why you’re getting _x and _y

Have you ever merged two #Python #Pandas data frames together, only to find that one column has a _x suffix, and another has a _y suffix?

Wonder where this comes from, and how you can change it?

I explain it all in my latest video: youtu.be/1hYIC4sT5dk?...

07.07.2025 14:43 — 👍 1    🔁 0    💬 0    📌 0
Why slicing Jan–June across years in Pandas is trickier than you think
YouTube video by Python and Pandas with Reuven Lerner Why slicing Jan–June across years in Pandas is trickier than you think

Want to know if the US dollar rose or fell each year? That's easy.

But if you want to know whether it rose or fell during the *first half* of each year? That's trickier!

In my latest video, I walk you through how to solve such a problem using #Python #Pandas: youtu.be/KMn16l7RoM4?...

07.07.2025 13:14 — 👍 1    🔁 0    💬 0    📌 0
How to run "git log" on deleted files — and restore them
YouTube video by Python and Pandas with Reuven Lerner How to run "git log" on deleted files — and restore them

Want to get the log of a file you deleted in Git?

Want to restore a file you deleted in a previous commit?

In my latest video, I show you how deleting (and un-deleting) work in Git, and why: youtu.be/oT4__qrXYy8?

04.07.2025 05:12 — 👍 2    🔁 1    💬 0    📌 0

@lernerpython.com is following 20 prominent accounts