About Train and test data

any logic behind to split the data into train and test.
if I need three columns for our project and total columns in the data set are 10. then can I split whole columns into train and test or can I split only 3 columns into train and test.

please give me answer briefly

Train Test split is important to check for over-fitting. You can’t evaluate your model on the data it was trained on because that would be misleading. The model has already seen those samples.

Also, Train Test split isn’t column based. First select all the columns you need. Discard all other columns from the complete dataset and then do the Train Test split.