• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

具有多列数据帧的值计数的单列

用户头像
it1352
帮助1

问题说明

我想用熊猫将多列的频率求和.列的数量可以在2至15列之间变化.这是仅3列的示例:

I would like to sum the frequencies over multiple columns with pandas. The amount of columns can vary between 2-15 columns. Here is an example of just 3 columns:

code1    code2    code3
27       5        56
534      27       78
27       312      55
89       312      27

我想得到以下结果:

code    frequency
5       1
27      4
55      1
56      2
78      1
312     2
534     1

要对一列内的值进行计数不是问题,只需要一个数据帧中所有频率的总和即可显示一个值,而不管列数如何.

To count values inside one column is not the problem, just need a sum of all frequencies in a dataframe a value can appear, no matter the amount of columns.

正确答案

#1

您可以查看全文

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /reply/detail/tanhceaeie
系列文章
更多 icon
同类精品
更多 icon
继续加载