CountsBy

CountsBy[{e1,e2,},f]

gives an association whose keys are the distinct values of the f[ei], and whose values give the number of times these f[ei] values appear.

CountsBy[f]

represents an operator form of CountsBy that can be applied to an expression.

Details

  • CountsBy[{e1,e2,},f] gives an association whose keys f[ei] are in the order in which the corresponding ei first appear.
  • CountsBy[f][expr] is equivalent to CountsBy[expr,f].

Examples

open allclose all

Basic Examples  (2)

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=

Use the operator form of CountsBy:

In[1]:=
Click for copyable input
Out[1]=

Properties & Relations  (1)

See Also

Counts  Tally  BinCounts  GroupBy  CountDistinctBy

Introduced in 2014
(10.0)