Python pandas 箱线图单列

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40026391/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 02:12:25  来源:igfitidea点击:

Python pandas box plot a single column

pandas

提问by Sanyo Mn

I'm trying to box plot a single column of the dataframe using pandas. However, I got no figure but a text output as shown below: thanks

我正在尝试使用 Pandas 对数据框的单列进行箱线图。但是,我没有得到图,只有如下所示的文本输出:谢谢

df.boxplot(column=['crim'])

"{'medians': [], 'fliers' [, ], 'whiskers': [, ], 'boxes': [], 'caps': [, ]}

"{'中位数': [], '传单' [, ], '胡须': [, ], '盒子': [], '大写': [, ]}

回答by piRSquared

versions

版本

import sys
import pandas as pd
import numpy as np

print(pd.__version__)
print(sys.version)

0.18.1
2.7.12 |Anaconda 4.0.0 (64-bit)| (default, Jun 29 2016, 11:07:13) [MSC v.1500 64 bit (AMD64)]

Also got same results with

也得到了相同的结果

print(sys.version)

3.5.2 |Anaconda 4.2.0 (64-bit)| (default, Jul  5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)]


consider the df

考虑 df

df = pd.DataFrame(np.random.randn(100, 5), columns=list('ABCDE'))

df.boxplot(return_type='axes');

enter image description here

在此处输入图片说明

both

两个都

df.boxplot(column=['A'], return_type='axes');

or

或者

df.boxplot(column='A', return_type='axes');

return

返回

enter image description here

在此处输入图片说明