>>> df = pd.DataFrame({'A' : ['foo', 'bar', 'foo', 'bar',
... 'foo', 'bar'],
... 'B' : [1, 2, 3, 4, 5, 6],
... 'C' : [2.0, 5., 8., 1., 2., 9.]})
>>> grouped = df.groupby('A')
>>> grouped.filter(lambda x: x['B'].mean() > 3.)
A B C
1 bar 2 5.0
3 bar 4 1.0
5 bar 6 9.0
spUtil.get('pps-list-modal', {title: c.data.editAllocations,
table: 'resource_allocation',
queryString: 'GROUPBYuser^resource_plan=' + c.data.sysId,
view: 'resource_portal_allocations' }).then(function(response) {
var formModal = response;
c.allocationListModal = response;
});
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;
}, {});
}