CountsBy
范例
打开所有单元 关闭所有单元基本范例 (2)
CountsBy[{1, 2, 3, 2, 1, 1}, EvenQ]CountsBy[Range[1000], PrimeQ]使用 CountsBy 的运算符形式:
CountsBy[PrimeQ][Range[1000]]范围 (1)
属性和关系 (3)
结果中的元素会按照 f[ei] 的值在列表中出现的顺序出现:
numbers = {0, 1, -1, I, -I, 1 + I, 1 - I, -1 + I, -1 + I}
CountsBy[numbers, Abs]CountsBy[Reverse[numbers], Abs]CountsBy[RotateLeft[numbers], Abs]CountsBy[list,f] 实际上就是 Counts[Map[f,list]]:
list = RandomInteger[{-1, 1}, 100];
CountsBy[list, Abs] === Counts[Map[Abs, list]]这里还要提到,CountsBy[list,Identity] 等价于 Counts[list]:
CountsBy[list, Identity] === Counts[list]CountsBy[expr,f] 等价于 GroupBy[expr,f,Length]:
CountsBy[{{a, b}, {b, c}, {a, d}}, First] == GroupBy[{{a, b}, {b, c}, {a, d}}, First, Length]相关指南
-
▪
- 关联 ▪
- 计算结构化数据集 ▪
- 数据集上的类数据库操作 ▪
- 函数式编程
文本
Wolfram Research (2014),CountsBy,Wolfram 语言函数,https://reference.wolfram.com/language/ref/CountsBy.html.
CMS
Wolfram 语言. 2014. "CountsBy." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/ref/CountsBy.html.
APA
Wolfram 语言. (2014). CountsBy. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/CountsBy.html 年
BibTeX
@misc{reference.wolfram_2026_countsby, author="Wolfram Research", title="{CountsBy}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/CountsBy.html}", note=[Accessed: 12-September-2026]}
BibLaTeX
@online{reference.wolfram_2026_countsby, organization={Wolfram Research}, title={CountsBy}, year={2014}, url={https://reference.wolfram.com/language/ref/CountsBy.html}, note=[Accessed: 12-September-2026]}