Onlyy columns are visible after spliiting the combined data set back into train and test!

data_science

#1

Hello all!!!
Used the following code to split data{combined dataset} into train and test again. But after doing so no row values are as such visible , rather only columns are visible.
Please help me out!!!
#Divide into test and train:
train = data.loc[data[‘source’]==“train”]
test = data.loc[data[‘source’]==“test”]


#2

Hi @sahil1995chaturvedi,

The following code is working for me:

train= pd.read_csv("~/train.csv")

test= pd.read_csv("~/test.csv")

train[“source”]=“train”

test[“source”]=“test”

Combine train and test dataset:

data= pd.concat([train,test],ignore_index=True)

Divide into test and train:

train = data.loc[black[‘source’]==“train”]
test = data.loc[black[‘source’]==“test”]


#3

Actually I made a typo of “Train” instead of ‘train’ in the original code.
Btw Thanks for your help brother!!!