I have created the user defined function in Python for Train test split. But after calling the function the shape is reduces to (4177, 8)

Viewed 18

Trying to create user defined function.After calling the function unable to see the Y.

def splitData(df,seed=42):
    y=df['Rings'] 
    x=df.drop(['Rings'],axis =1)
    x_train, x_test, y_train, y_test = train_test_split(x,y, train_size=0.70)
    return x_train,x_test,y_train,y_test

try:
    train_data=splitData(ablone_df)[0]
    test_data=splitData(ablone_df)[1]
except:
    print("Error")

print("train_data.shape:",train_data.shape)
print("test_data:" ,test_data.shape)
print("Original Shape:" ,ablone_df.shape)

train_data.shape: (2923, 8) test_data: (1254, 8) Original Shape: (4177, 9)

0 Answers
Related