Locating the n-smallest and n-largest values

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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset