Sometime we need to know the n-smallest and n-largest values in a dataset. These can be found using .nsmallest() and .nlargest(). The following code demonstrates this by returning the 4-smallest values for MSFT.
And likewise, the 4-largest values.
The form for a series is slightly different since there are no columns to specify.