df
Purchase
1
3
2
5
4
7
df2
df2 = pd.DataFrame(columns=['Mean','Median','Max','Col4'])
df2 = df2.append({'Mean': (df['Purchase'].mean()),'Median':df['Purchase'].median(),'Max':(df['Purchase'].max()),'Col4':(df2[['Mean','Median']].min(axis=1))}, ignore_index=True)
Output obtained
Mean Median Max Col4
3.66 3.5 7 Series([], dtype: float64)
Output expected
Mean Median Max Col4
3.66 3.5 7 3.5 #Value in Col4 is Min(Mean, Median of df2)
Can anyone help?
Use
np.minimum
and passedmean
withmedian
:Or better is use
Series.agg
with new value of min in next step, last create one row DataFrame: