December 2018
Beginner to intermediate
682 pages
18h 1m
English
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