【发布时间】:2019-05-02 05:20:47
【问题描述】:
给定
patient_id test_result has_cancer
0 79452 Negative False
1 81667 Positive True
2 76297 Negative False
3 36593 Negative False
4 53717 Negative False
5 67134 Negative False
6 40436 Negative False
如何在python中计算一列中的False或True?
我一直在尝试:
# number of patients with cancer
number_of_patients_with_cancer= (df["has_cancer"]==True).count()
print(number_of_patients_with_cancer)
【问题讨论】:
标签: python pandas dataframe count