计算字符串在特定列中出现的次数

Count the number of times a string appears in a specific column

我有几列有 3 个可能的结果,它们是:

  1. Yes
  2. No
  3. N.A.(Not Apply)

如何创建一个卡片可视化,其中包含单词 'No' 在所选列中出现的总次数。

您可以使用 value_counts() 进行计数

   df['column_name'].value_counts()

使用它您可以计算特定实体在该列中重复的次数

len(df[df['column_name'] == "Yes"])

如果列的各种值需要,只需将值替换为其他类型,例如是,否,N.A