What is a function anyway? In programming, a function is a named section of code that encapsulates a specific task and can be used relatively independently of surrounding code. Most (but not all) functions are stateless—their outcome depends solely on the function's explicit inputs.
Functions are ubiquitous in Python code. In fact, we have used some functions already; print is one example. Those functions are part of Python's default arsenal of built-in functions. There are 69 built-in functions in total in modern pandas. Before we start writing functions on our own, let's review these built-in functions first.
In the following sections, we will discuss just a handful of functions that we'll use frequently throughout the book; some others we'll discuss later. We have grouped all functions into four groups depending on the...