I wanted to show you a much cleaner and performant way that you can write the code. Create the conditions and use ~
to drop the rows that meet those conditions. I hope this helps:
a1 = popular_trio['actor_1_facebook_likes']
a2 = popular_trio['actor_2_facebook_likes']
a3 = popular_trio['actor_3_facebook_likes']
c1 = (a1/2) < a2
c2 = (a2/2) < a1
c3 = (a3/2) < a2
c4 = (a1/2) < a3
c5 = (a2/2) < a3
c6 = (a3/2) < a1
popular_trio[~(c1|c2|c3|c4|c5|c6)] # or try popular_trio[~((c1)|(c2)|(c3)|(c4)|(c5)|(c6))]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.