Aggregates a data array by merging groups of elements, similar to the GROUP BY clause in SQL statements.
This primary usage of this method is for changing data resolution, such as to convert a daily data into weekly data.
If the data is from a database, aggregation can often be more efficiently and conveniently performed by using the GROUP BY clause of SQL. This method should only be used when the data are not coming from a database, or the aggregation method are not supported by the database used.
In this method, the ArrayMath object represents the delimiters used to group elements in the srcArray
. The positions of all non-NoValue
elements in the ArrayMath object will be used as delimiters positions.
For example, if the ArrayMath object consists of an array of 50 elements, and only the elements at 0, 10, 20, 30, 40 are not NoValue, then the groups will be defined as positions 0 - 9, 10 - 19, 20 - 29, 30 - 39 and 40 - 49.
Note that a group includes the starting delimiter position but excludes the ending delimiter position.
The ArrayMath object is typically created by applying ArrayMath.selectStartOfHour
to a data array.
For example, to group daily data into weekly data, one may create an ArrayMath object with the dates of the daily data, then ArrayMath.selectStartOfWeek
to select only the elements representing the start of a week. The resulting ArrayMath object can then be used to aggregate daily data into weekly data.
Due to aggregation, the length of the output array will usually be shorter than, and never be longer than, the length of the input array.
© 2017 Advanced Software Engineering Limited. All rights reserved.