Doubt in numpy slicing

In numpy what is the difference between these, x=train[i,:-1] and y=train[i,-1]

Hello @raushan.iitdhn,

x = train[i,:-1] #this will slice the array such that x has the ith row and all columns except the last one of train.
y = train[i,-1] #this will slice the array such that x has ith row and last column of train.

Hope this helps with your doubt.

Thanks :slightly_smiling_face:

1 Like