Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pandas version 2.1.4 method mad()

I looked in the documentation for version 2.1.4 and didn't find anything about Mean Absolute Deviation, which in previous versions was mad(). Can anyone tell me which method in the current version works like mad()?

like image 565
Igor Galvao Bezerra Avatar asked May 17 '26 02:05

Igor Galvao Bezerra


1 Answers

mad() method has been deprecated, however, you can still calculate the MAD manually using simple formula with the mean() method and absolute differences.

Here's the code.

import pandas as pd

s = pd.Series([2, 3, 5, 7, 11])

# Compute MAD manually
mad = (s - s.mean()).abs().mean()

print(mad)

I hope this will help you a little.

like image 91
skyhugger Avatar answered May 18 '26 18:05

skyhugger



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!