相关疑难解决方法(0)

同一图中的大熊猫数据框的多列的箱形图(seaborn)

我觉得我可能没想到明显的东西.我想在同一个图中输入数据帧每一列的方框图,在x轴上我有列的名称.在seaborn.boxplot()这将是groupby每列的等于.

在熊猫我会做

df = pd.DataFrame(data = np.random.random(size=(4,4)), columns = ['A','B','C','D'])
df.boxplot()
Run Code Online (Sandbox Code Playgroud)

产量

在此输入图像描述

现在我想在seaborn得到同样的东西.但是当我尝试sns.boxplot(df)时,我只得到一个分组的boxplot.如何在seaborn中重现相同的数字?

谢谢

python pandas seaborn

13
推荐指数
2
解决办法
2万
查看次数

多列的大熊猫盒子图

我的数据框架(熊猫的结构)如上所示 在此输入图像描述

现在我想在单独的画布上为每个功能制作boxplot.分离条件是第一列.我有类似的直方图图(下面的代码),但我不能为boxplot制作工作版.

 hist_params = {'normed': True, 'bins': 60, 'alpha': 0.4}
# create the figure
fig = plt.figure(figsize=(16,  25))
for n, feature in enumerate(features):
    # add sub plot on our figure
    ax = fig.add_subplot(features.shape[1] // 5 + 1, 6, n + 1)
    # define range for histograms by cutting 1% of data from both ends
    min_value, max_value = numpy.percentile(data[feature], [1, 99])
    ax.hist(data.ix[data.is_true_seed.values == 0, feature].values, range=(min_value, max_value), 
             label='ghost', **hist_params)
    ax.hist(data.ix[data.is_true_seed.values == 1, feature].values, range=(min_value, max_value), 
             label='true', **hist_params)
    ax.legend(loc='best')

    ax.set_title(feature)
Run Code Online (Sandbox Code Playgroud)

上面的代码生成了这样的输出(仅附加了它的一部分): 在此输入图像描述

python boxplot pandas

4
推荐指数
1
解决办法
1万
查看次数

标签 统计

pandas ×2

python ×2

boxplot ×1

seaborn ×1