In this section, we will learn how to apply Python's pre-built and self-built functions to pandas data objects. We'll also learn about applying functions to a pandas series and pandas DataFrame.
We will begin by importing the pandas module into our Jupyter Notebook:
import pandas as pd import numpy as np
We will then read in our CSV dataset:
data = pd.read_csv('data-titanic.csv')data.head()
Let's proceed to applying functions using pandas' apply method. In this example, we will creating a function using lambda, as follows:
func_lower = lambda x: x.lower()
Here, we pass a value x and converting ...