Just a small note: mad() was deprecated in pandas. Now, they'd like us to write the whole formula again Ref: https://pandas.pydata.org/pandas-docs/version/1.5/reference/api/pandas.DataFrame.mad.html