简体   繁体   中英

How do you combine two split data back into original (numpy)

I have a data named Total and I split it into features and labels as below. Later I split them into training and test data.

Total_X = Total[:,:-1]
Total_y = Total[:,-1]

Train_X , Test_X , Train_y, Test_y = train_test_split(Total_X,Total_y,test_size = .3)

Now I want to combine Train_X and Train_y and create a new list which is like Total .

Are you sure you wanted to divide them in the first place?

test_len = np.floor(len(Total) * 0.3)
test_xy, train_xy = Total[:test_len], Total[test_len:]

And then if you need them, you can extract test_x = test_xy[:,:-1] etc

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM