原本样例
train_list = train_test.values.tolist()
#去除0元素
for i in range(len(train_list)):
length = len(train_list[i])
x = 0
while x < length:
if train_list[i][x] == 0:
train_list[i].remove(train_list[i][x])
x -= 1
length -= 1
x += 1
结果