我使用的是二进制分类数据集。我想要一个计划,第一栏显示人们的年龄,下一栏显示一年级学生的年龄,第三栏显示二年级学生的年龄。请告诉我该怎么做
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
df = pd.read_csv (r'test.csv')
firstClassDf = df[df['class'] == '0']
print(firstClassDf.shape)
print(firstClassDf.head())
secondClassDf = df[df['class'] == '1']
print(secondClassDf.shape)
boxplot1 = df.boxplot(column='age')
plt.figure()
boxplot2 = firstClassDf.boxplot(column='age')
plt.figure()
boxplot3 = secondClassDf.boxplot(column='age')
plt.figure()
print(plt.show())
从评论中,我了解到您正在寻找以下内容:
相关问题 更多 >
编程相关推荐