【发布时间】:2021-07-23 16:25:57
【问题描述】:
我正在使用二进制分类数据集,我正在尝试绘制所有样本的年龄,其中 class== 1 的样本和 class== 0 的样本? 我想知道如何合并 firstDf、secondDf 和 thirdDf 并将它们显示在 python 的一个箱线图中?
age | class
------------
1 | 1
2 | 1
3 | 0
4 | 1
5 | 0
6 | 1
7 | 1
8 | 0
9 | 0
10 | 1
import pandas as pd
import matplotlib.pyplot as plt
data = [['age', 'class'],
[1,1],
[2,1],
[3,0],
[4,1],
[5,0],
[6,1],
[7,1],
[8,0],
[9,0],
[10,1]]
firstDf = df['age']
secondDf = [df[df['class'] == 0]['age']]
thirdDf = [df[df['class'] == 1]['age']]
预期情节
【问题讨论】:
标签: python python-3.x matplotlib seaborn data-science