pandas划分数据

pandas划分数据_第1张图片

 

1.根据列位置划分

execldata = pd.read_excel(filepath)
# 获取列数
bandscount = execldata.shape[1]
#去除最后一列数据类别
bandscount = bandscount - 1
classifypointdata = execldata[:, 0:bandscount]
classifypointlabel = execldata[:, -1]

2.根据字段名称进行划分

execldata = pd.read_excel(filepath)
#分类字段
Classificationfield = 'MnCLASS'
classifypointdata = execldata.drop(columns=[Classificationfield])
classifypointlabel = execldata[Classificationfield]

你可能感兴趣的:(python,python,pandas)