positions = data['预期岗位'].str.strip('[]').str.replace("'", "").str.split(',', expand=True) positions.columns = ['position_{}'.format(i) for i in range(positions.shape[1])] positions = positions.apply(LabelEncoder().fit_transform) onehot = OneHotEncoder() positions = onehot.fit_transform(positions)什莫意思
时间: 2023-06-08 12:09:18 浏览: 91
这段代码是针对一个数据集中的"预期岗位"列进行数据清洗和处理的代码,将预期岗位列中的'[]'字符串替换为空字符串,并将每个职位名称中的单引号删除,然后将职位名称分割成多个列,并使用LabelEncoder将职位名称进行编码,最后再使用OneHotEncoder将职位名称转换成独热编码。
相关问题
switch (Form) { case 1: p1 = CPoint(PositionS.x, PositionS.y); p2 = CPoint(PositionS.x + 48, PositionS.y); p3 = CPoint(PositionS.x + 61, PositionS.y); p4 = CPoint(PositionS.x + 100, PositionS.y); //p5 = CPoint(PositionS.x + 53, PositionS.y + 15); //p6 = CPoint(PositionS.x + 68, PositionS.y + 41); if (Status == 0) { p7 = CPoint(PositionS.x + 40, PositionS.y); p8 = CPoint(PositionS.x + 60, PositionS.y); } else if (Status == 1) { p7 = CPoint(PositionS.x + 49, PositionS.y + 5); p8 = CPoint(PositionS.x + 58, PositionS.y + 21); } break; case 2: p1 = CPoint(PositionS.x + 100, PositionS.y); p2 = CPoint(PositionS.x + 52, PositionS.y); p3 = CPoint(PositionS.x + 39, PositionS.y); p4 = CPoint(PositionS.x, PositionS.y); //p5 = CPoint(PositionS.x + 47, PositionS.y + 15); //p6 = CPoint(PositionS.x + 32, PositionS.y + 41); if (Status == 0) { p7 = CPoint(PositionS.x + 40, PositionS.y); p8 = CPoint(PositionS.x + 60, PositionS.y); } else if (Status == 1) { p7 = CPoint(PositionS.x + 51, PositionS.y + 5); p8 = CPoint(PositionS.x + 42, PositionS.y + 21); } break; case 3://11道岔 p1 = CPoint(PositionS.x, PositionS.y); p2 = CPoint(PositionS.x + 48, PositionS.y); p3 = CPoint(PositionS.x + 61, PositionS.y); p4 = CPoint(PositionS.x + 100, PositionS.y); p5 = CPoint(PositionS.x + 53, PositionS.y - 15); p6 = CPoint(PositionS.x + 68, PositionS.y - 41); if (Status == 0) { p7 = CPoint(PositionS.x + 40, PositionS.y); p8 = CPoint(PositionS.x + 60, PositionS.y); } else if (Status == 1) { p7 = CPoint(PositionS.x + 49, PositionS.y - 5); p8 = CPoint(PositionS.x + 58, PositionS.y - 21); } break; case 4://12道岔 p1 = CPoint(PositionS.x + 100, PositionS.y); p2 = CPoint(PositionS.x + 52, PositionS.y); p3 = CPoint(PositionS.x + 39, PositionS.y); p4 = CPoint(PositionS.x, PositionS.y); p5 = CPoint(PositionS.x + 47, PositionS.y - 15); p6 = CPoint(PositionS.x + 32, PositionS.y - 41); if (Status == 0) { p7 = CPoint(PositionS.x + 40, PositionS.y); p8 = CPoint(PositionS.x + 60, PositionS.y); } else if (Status == 1) { p7 = CPoint(PositionS.x + 51, PositionS.y - 5); p8 = CPoint(PositionS.x + 42, PositionS.y - 21); } break; }
这段代码是一个switch语句,根据变量Form的值来给p1、p2、p3、p4、p5、p6、p7和p8赋不同的坐标值。其中,如果Form的值为1,则p1的坐标为(PositionS.x, PositionS.y),p2的坐标为(PositionS.x + 48, PositionS.y),p3的坐标为(PositionS.x + 61, PositionS.y),p4的坐标为(PositionS.x + 100, PositionS.y);如果Form的值为2,则p1的坐标为(PositionS.x + 100, PositionS.y),p2的坐标为(PositionS.x + 52, PositionS.y),p3的坐标为(PositionS.x + 39, PositionS.y),p4的坐标为(PositionS.x, PositionS.y);如果Form的值为3,则p1的坐标为(PositionS.x, PositionS.y),p2的坐标为(PositionS.x + 48, PositionS.y),p3的坐标为(PositionS.x + 61, PositionS.y),p4的坐标为(PositionS.x + 100, PositionS.y),p5的坐标为(PositionS.x + 53, PositionS.y - 15),p6的坐标为(PositionS.x + 68, PositionS.y - 41);如果Form的值为4,则p1的坐标为(PositionS.x + 100, PositionS.y),p2的坐标为(PositionS.x + 52, PositionS.y),p3的坐标为(PositionS.x + 39, PositionS.y),p4的坐标为(PositionS.x, PositionS.y),p5的坐标为(PositionS.x + 47, PositionS.y - 15),p6的坐标为(PositionS.x + 32, PositionS.y - 41)。根据Status的值不同,p7和p8也会有不同的坐标值。
p1 = CPoint(PositionS.x + 100, PositionS.y); p2 = CPoint(PositionS.x + 52, PositionS.y); p3 = CPoint(PositionS.x + 39, PositionS.y); p4 = CPoint(PositionS.x, PositionS.y); p5 = CPoint(PositionS.x + 47, PositionS.y - 15); p6 = CPoint(PositionS.x + 32, PositionS.y - 41); if (Status == 0) { p7 = CPoint(PositionS.x + 40, PositionS.y); p8 = CPoint(PositionS.x + 60, PositionS.y); } else if (Status == 1) { p7 = CPoint(PositionS.x + 51, PositionS.y - 5); p8 = CPoint(PositionS.x + 42, PositionS.y - 21); }
这段代码定义了七个点的坐标,它们分别是p1、p2、p3、p4、p5、p6、p7和p8,它们的具体坐标值是通过PositionS.x和PositionS.y计算得出的。其中,如果Status为0,则p7的坐标为(PositionS.x + 40, PositionS.y),p8的坐标为(PositionS.x + 60, PositionS.y);如果Status为1,则p7的坐标为(PositionS.x + 51, PositionS.y - 5),p8的坐标为(PositionS.x + 42, PositionS.y - 21)。
阅读全文