Python使用布尔过滤数据框

时间:2019-10-23 08:02:03

标签: python pandas dataframe

我的输入数据框如下所示;

Name           Class         CoverPeriod      LeadTime
BXB            A             5                5
BYA            B             4                4  
CYC            B             3                2
DDB            B             1                1

我编写了这样的代码来计算不相等的“ CoverPeriod”和“ LeadTime”列。

count = df.LeadTime.ne(df.CoverPeriod).sum()
print(count)
1

但是,除了“ count”数字外,我还想使用以下“ count_list”代码获取值彼此不相等的行:

count_list=df.LeadTime.ne(df.CoverPeriod)

所需的输出为;

Name           Class         CoverPeriod      LeadTime
CYC            B             3                2

您能帮我吗?

0 个答案:

没有答案