AggregatedEntityClass
AggregatedEntityClass[class,"prop"f]
represents an entity class containing a single entity with the property prop whose value is the result of applying the function f to the whole specified entity class.
AggregatedEntityClass[class,{"prop1"f1,"prop2"f2,…}]
constructs multiple properties propi obtained by applying fi to class.
AggregatedEntityClass[class,propspec,gprop]
forms groups of elements of class according to their values of the property gprop, then generates an entity class with an entity for each of these groups.
AggregatedEntityClass[class,propspec,"pname"f]
forms groups according to the values obtained by applying the entity function f, with the resulting property named pname.
AggregatedEntityClass[class,propspec,{gspec1,gspec2,…}]
forms groups for which the set of values defined by the gspeci is distinct.
Details
- In AggregatedEntityClass[class,"prop"f], the function f can either be an EntityFunction[…] object or a function fun that will be treated as EntityFunction[x,fun[x["prop"]]].
- In AggregatedEntityClass[class,propspec], EntityFunction objects in propspec are in effect applied to an association of properties whose values are the list of values for the entities in class.
- EntityFunction expressions appearing in the second argument of AggregatedEntityClass are not applied to single entities in the first argument, but rather to the whole first argument, if no third argument is present, or to the entity classes obtained by grouping according to the third argument.
- EntityFunction expressions appearing in the third argument of AggregatedEntityClass are applied separately to the individual entities in the first argument.
- Unlike GroupBy, AggregatedEntityClass[class,propspec,{prop1,prop2,…}] does not perform hierarchical grouping if its third argument is a list; rather, it will create a class with a number of entities given by the distinct values of EntityValue[class,{prop1,prop2,…}].
- EntityProperties[AggregatedEntityClass[class,{"name1"->entityfunc1,"name2"->entityfunc2,…},{"prop1","prop2",…}]] returns {EntityProperty[agg,"name1"],EntityProperty[agg,"name2"],…,EntityProperty[agg,"prop1"],EntityProperty[agg,"prop2"],…} where agg is the whole AggregatedEntityClass expression.
Examples
open allclose allBasic Examples (3)
Create an aggregation of all countries and compute their total area:
An equivalent computation, suitable for small datasets:
Find the mean atomic mass for elements in each period class:
When used with relational-database-backed entities, a two-argument AggregatedEntityClass corresponds to using aggregate functions in the SELECT statement:
Compute the total amount of payments:
Compute the maximum credit limit by country (similar to a GROUP BY statement in SQL languages):
Scope (2)
The third argument can be an EntityFunction:
Apply a function to the result, typically an aggregation function:
Properties & Relations (2)
AggregatedEntityClass generates entities that correspond to groups:
Single entities obtained from AggregatedEntityClass effectively correspond to implicit entities:
Text
Wolfram Research (2019), AggregatedEntityClass, Wolfram Language function, https://reference.wolfram.com/language/ref/AggregatedEntityClass.html.
CMS
Wolfram Language. 2019. "AggregatedEntityClass." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/AggregatedEntityClass.html.
APA
Wolfram Language. (2019). AggregatedEntityClass. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/AggregatedEntityClass.html