Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
326 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 Reply

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...