Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

groupby

function groupBy(array, keyFn) {
  return array.reduce((accumulator, value) => {
    const key = keyFn(value);
    if (!accumulator[key]) {
      accumulator[key] = [value];
    } else {
      accumulator[key] = [value];
    }
    return accumulator;
  }, {});
}
Source by www.edureka.co #
 
PREVIOUS NEXT
Tagged: #groupby
ADD COMMENT
Topic
Name
2+6 =