Operators and Dunder Methods

Learn the operators and magic of dunder methods found in Series.

Operators or dunder methods (short for double underscore methods) are the protocols that determine how the Python language reacts to operations. For example, when we use the + operation, Python is dispatching to the __add__ method. When we use a loop with a for statement, Python dispatches to the __iter__ method.

This won’t be a deep treatise on dunder methods or magic methods.

Let’s look at how this works with a pandas Series.

Dunder methods

Here’s an example in pure Python:

Get hands-on with 1200+ tech skills courses.