What's the difference between [:5]
and [5]
in this Python code?
y_test_predicted = model.predict(X_test)
residuals = Y_test - y_test_predicted
print(residuals[:5])
print(residuals[5])
What's the difference between [:5]
and [5]
in this Python code?
y_test_predicted = model.predict(X_test)
residuals = Y_test - y_test_predicted
print(residuals[:5])
print(residuals[5])
you can find a useful information about slicing in this link.
Refer to below simple example to understand it as a glimpse:
list = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'i', 'j']
print(list[5]) #it will print: f
print(list[:5]) #it will print: ['a', 'b', 'c', 'd', 'e'], indices form 0 to 4
#List Slicing: list[start:stop:step]