简体   繁体   English

熊猫:使用&运算符过滤行不会减少数据框

[英]Pandas: filtering rows with & operator does not reduce Dataframe

I have been reviewing some Posts on stack overflow, but have not found an appropriate answer to my question. 我一直在审查堆栈溢出中的一些帖子,但没有找到对我的问题的适当答案。 I have a dataframe with three columns: player_name, dribbling and pace 我有一个包含三列的数据框:player_name,盘带和速度

df2[df2['pace']>50 & (df2['dribbling']>50)].count()

shows 16882 entries, which is the whole dataset 显示16882个条目,这是整个数据集

df2[df2['pace']>50].count()

shows 15713 entries and 显示15713个条目,并且

df2[df2['dribbling']>50].count()

shows 15089 entries 显示15089个条目

Why does the df2[df2['pace']>50 & (df2['dribbling']>50)].count() not reduce the dataset and instead shows all entries? 为什么df2[df2['pace']>50 & (df2['dribbling']>50)].count() 不会减少数据集,而是显示所有条目?

尝试这个:

df2[(df2['pace']>50) & (df2['dribbling']>50)].count()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM