Chaining Series methods
In Python, every variable points to an object, and many attributes and methods return new objects. This allows sequential invocation of methods using attribute access. This is called method chaining or flow programming. pandas is a library that lends itself well to method chaining, as many Series and DataFrame methods return more Series and DataFrames, upon which more methods can be called.
To motivate method chaining, let's take an English sentence and translate the chain of events into a chain of methods. Consider the sentence: A person drives to the store to buy food, then drives home and prepares, cooks, serves, and eats the food before cleaning the dishes.
A Python version of this sentence might take the following form:
(person.drive('store')
.buy('food')
.drive('home')
.prepare('food')
.cook('food')
.serve('food')
.eat('food...