In the previous recipe, Combining multiple features with statistical operations, we created new features by performing statistical operations across several variables. Some mathematical operations, however, such as subtraction or division, make more sense when performed between two features, or when considering multiple features against one reference variable. These operations are very useful to derive ratios, such as the debt-to-income ratio:
debt-to-income ratio = total debt / total income
Or we can use them for differences, for example, the disposable income:
disposable income = income - total debt
In this recipe, we will learn how to derive new features by subtraction or division utilizing pandas, and more generally, we will learn how to perform operations against one reference variable.