In the Python version of the book we teach how to get the K largest / smallest values by using
sort_values + head
nlargest/nsmallest (NB: this is slightly more efficient. O(N) instead of O(N logN). Not a big difference in practice.)
In the R book we might want to consider mimicking this with top_n and bottom_n (if I recall these are the funcs that do the same thing)
Should come back to this once the Python book is stabilized. Right now we do nlargest/nsmallest in Ch5 (in k-nearest neighbours stuff), but we might move it back to Ch1 and then just use nlargest/smallest in ch5...
If we do change this in the R version, we should make sure to update the list of K-NN steps (after section on computing distances) to be 3 items instead of 4
In the Python version of the book we teach how to get the K largest / smallest values by using
sort_values
+head
nlargest
/nsmallest
(NB: this is slightly more efficient. O(N) instead of O(N logN). Not a big difference in practice.)In the R book we might want to consider mimicking this with
top_n
andbottom_n
(if I recall these are the funcs that do the same thing)Should come back to this once the Python book is stabilized. Right now we do nlargest/nsmallest in Ch5 (in k-nearest neighbours stuff), but we might move it back to Ch1 and then just use nlargest/smallest in ch5...