Say I have
r = pd.DataFrame({'A':1 , 'B':pd.Series(1,index=list(range(4)),dtype='float32')})
And r['B'].describe()[['mean','std','min','max']] gives the result:
mean 1.0 std 0.0 min 1.0 max 1.0 Name: B, dtype: float64
But from the above output, how do I get rid or break the last line " Name:B, dtype: float64 "
I figured out one way to achieve this
x=r['B'].describe()[['mean','std','min','max']] print "mean ",x['mean'],"\nstd ",x['std'],"\nmin ",x['min'],"\nmax ",x['max']
which gives the desired result:
mean 1.0 std 0.0 min 1.0 max 1.0
Is there any cleaner to achieve this result directly from pd.describe ()
python pandas format dataframe series
sus
source share