Python中从ndarray或者DataFrame里获取数据和标签 2019 年7 月23 日 如果我们有一个ndarray, 最后一列是label,前面几列是data, 我们可以通过如下的方式去获取数据(假如我们有9列): 1 2 X = dataset[:,0:-1] or X = dataset[:,0:8] Y = dataset[:,8] 如果我们有个DataFrame, 我们可以通过如下的方式去获取: 1 X, y = data.iloc[:,:-1], data.iloc[:,-1]