There's more...

Pandas actually has built-in methods clip, clip_lower, and clip_upper that replicate this operation. The clip method can set a floor and ceiling at the same time. We also check whether this alternate method produces the exact same Series, which it does:

>>> fb_likes_cap2 = fb_likes.clip(lower=300, upper=20000)
>>> fb_likes_cap2.equals(fb_likes_cap)
True
..................Content has been hidden....................

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