简体   繁体   中英

Training and Testing Splitting Tagging

Here is my dataset:

import pandas as pd 
fileName= 'user.csv'
df = pd.read_csv("trainingsample_100k_apps.csv",sep=",",header=0)
pd.set_option('max_columns', None)
df

UserID  Total Usage
001       20.3
002       40.5
003       10.1

How can I know which row have been selected as training and testing after I applied this query:

train, test = train_test_split(df, test_size = 0.20)

I want the output to be like this:

UserID  Total Usage   SplitingCategory
001       20.3        Training
002       40.5        Testing
003       10.1        Training

Ok i got the answer

test

and it will appear my test dataset

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