I see that the pandas library has a Describe by
function which returns some useful statistics. However, is there a way to add additional rows to the output such as
Try this:
df.describe()
num1 num2
count 3.0 3.0
mean 2.0 5.0
std 1.0 1.0
min 1.0 4.0
25% 1.5 4.5
50% 2.0 5.0
75% 2.5 5.5
max 3.0 6.0
Build a second DataFrame.
pd.DataFrame(df.mad() , columns = ["Mad"] ).T
num1 num2
Mad 0.666667 0.666667
Join the two DataFrames.
pd.concat([df.describe(),pd.DataFrame(df.mad() , columns = ["Mad"] ).T ])
num1 num2
count 3.000000 3.000000
mean 2.000000 5.000000
std 1.000000 1.000000
min 1.000000 4.000000
25% 1.500000 4.500000
50% 2.000000 5.000000
75% 2.500000 5.500000
max 3.000000 6.000000
Mad 0.666667 0.666667