如何在matplotlib中绘制两组数据框列的箱线图

how to plot a box plot of a column of a data frame in two groups in matplotlib

我有以下数据框:

       value    total_spend margin
            1   29493.14    10203.37
            1   27551.22    19003.07
            2   22881.26    15142.68
            1   15254.77    12337.22
            1   11873.95    9424.23
            1   11382.89    8767.83
            1   11006.11    6867.29
            2   9647.16    7543.24
            2   9227.57    9227.57
            1   9077.39    6541.60
            1   8912.10    4074.26
            2   8560.05    7466.30
            1   8041.52    7425.49
            1   8007.19    5850.35
            1   7914.47    3363.42
            2   7812.48    4185.71
            2   7441.81    7341.23
            1   7388.98     6871.19

我需要为每组 'value' 从“total_spend”列制作一个双箱线图。同一图中的两个箱线图

df.boxplot(column='total_spend', by='value')