Slicing can be used to remove records from a data frame. It is a process similar to Boolean selection where we select out all of the rows except for the ones you want removed.
Suppose we want to remove all but the first three records from sp500. The slice to perform this task is [:3] which returns the first three rows.
Remember, that since this is a slice, the result is a view into the original data frame. The rows have not been removed from the sp500 data, and changes to these three rows will change the data in sp500. The proper action to prevent this is to make a copy of the slice which results in a new data frame with the data for the specified rows copied.