Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
329 views
in Technique[技术] by (71.8m points)

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

I have the following data frame:

       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

i need to make a two box plot from'total_spend' column for every group of 'value' . two box plot in the same plot

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
df.boxplot(column='total_spend', by='value')

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...