Questions tagged [grouping]

The process of grouping entities into collections of associated elements.

Grouping is a form of hierarchical knowledge representation, similar to mind mapping, concept mapping and argument mapping, all of which need to observe at least some of the principles of grouping.

SQL Server - Indicates whether a specified column expression in a GROUP BY list is aggregated or not. Read more about this

Wiki Links

7381 questions
28
votes
7 answers

Group elements of an array by some property

I have an array of objects with property date. What I want is to create array of arrays where each array will contain objects with the same date. I understand, that I need something like .filter to filter objects, and then .map to add every thing to…
Alexey K
  • 6,537
  • 18
  • 60
  • 118
28
votes
1 answer

Bash command groups: Why do curly braces require a semicolon?

I know the difference in purpose between parentheses () and curly braces {} when grouping commands in bash. But why does the curly brace construct require a semicolon after the last command, whereas for the parentheses construct, the semicolon is…
Digital Trauma
  • 15,475
  • 3
  • 51
  • 83
28
votes
2 answers

How to use enum with grouping and subgrouping hierarchy/nesting

I have one enum 'class' called Example as follows: enum Example { //enums belonging to group A: enumA1, enumA2, enumA3, //enums belonging to group B: enumB1, enumB2, enumB3, //enums belonging to group C: enumC1, enumC2, …
user2763361
  • 3,789
  • 11
  • 45
  • 81
27
votes
5 answers

array.groupBy in TypeScript

The basic array class has .map, .forEach, .filter, and .reduce, but .groupBy i noticably absent, preventing me from doing something like const MyComponent = (props:any) => { return (
{ props.tags …
Eldamir
  • 9,888
  • 6
  • 52
  • 73
27
votes
3 answers

Python Pandas max value in a group as a new column

I am trying to calculate a new column which contains maximum values for each of several groups. I'm coming from a Stata background so I know the Stata code would be something like this: by group, sort: egen max = max(odds) For example: data =…
Vicki
  • 315
  • 1
  • 3
  • 6
26
votes
3 answers

How to assign the same style to a group of edges?

I've got a graph that I want graphviz to layout and visualize for me. The graph has 122 edges and 123 nodes. The edges are of 4 different kinds and I want them to be visually distinguishable. However I've not yet decided what would be the best way…
Vilx-
  • 104,512
  • 87
  • 279
  • 422
25
votes
7 answers

Group by multiple columns and sum other multiple columns

I have a data frame with about 200 columns, out of them I want to group the table by first 10 or so which are factors and sum the rest of the columns. I have list of all the column names which I want to group by and the list of all the cols which I…
user1042267
  • 303
  • 1
  • 3
  • 8
25
votes
1 answer

'Could not interpret input' error with Seaborn when plotting groupbys

Say I have this dataframe d = { 'Path' : ['abc', 'abc', 'ghi','ghi', 'jkl','jkl'], 'Detail' : ['foo', 'bar', 'bar','foo','foo','foo'], 'Program': ['prog1','prog1','prog1','prog2','prog3','prog3'], 'Value' :…
marshallbanana
  • 435
  • 1
  • 4
  • 9
25
votes
4 answers

WPF DataGrid Virtualization with Grouping

I'm using the WPF DataGrid from CodePlex and I need to get Virtualization to work with grouping. This question is on topic and points to an MSDN Example but it only covers ListControls with with simple (i.e. single 'column') DataTemplates.…
Jan Bannister
  • 4,859
  • 8
  • 38
  • 45
24
votes
7 answers

NullPointerException: element cannot be mapped to a null key

I have read the topic: Collectors.groupingBy doesn't accept null keys But I don't understand how can I apply it for my issue: my code: Map> mappingEntryMap = mapping.getMappingEntries() .stream() …
gstackoverflow
  • 36,709
  • 117
  • 359
  • 710
24
votes
7 answers

How to sum elements at the same index in array of arrays into a single array?

Let's say that I have an array of arrays, like so: [ [0, 1, 3], [2, 4, 6], [5, 5, 7], [10, 0, 3] ] How do I generate a new array that sums all of the values at each position of the inner arrays in javascript? In this case, the result would…
hmlee
  • 877
  • 1
  • 9
  • 22
23
votes
5 answers

Group array values based on key in php?

I have a array like this: $str= Array ( [No] => 101 [Paper_id] => WE3P-1 [Title] => "a1" [Author] => ABC [Aff_list] => "University of South Florida, Tampa, United States" [Abstracts] => "SLA" ) Array ( [No] => 101 …
Aditya
  • 4,453
  • 3
  • 28
  • 39
23
votes
4 answers

How to group items by index? C# LINQ

Suppose I have var input = new int[] { 0, 1, 2, 3, 4, 5 }; How do I get them grouped into pairs? var output = new int[][] { new int[] { 0, 1 }, new int[] { 2, 3 }, new int[] { 4, 5 } }; Preferably using LINQ
Jader Dias
  • 88,211
  • 155
  • 421
  • 625
22
votes
1 answer

How to get ordered type of Map from method Collectors.groupingBy

I need to separate list of data into different lists by type, for this purpose I use construction Map> dishMap = menu.stream() .collect(Collectors.groupingBy(Dish::getType)); but How can I get LinkedHashMap instead…
21
votes
5 answers

Select top N rows from each group

I use mongodb for my blog platform, where users can create their own blogs. All entries from all blogs are in an entries collection. The document of an entry looks like: { 'blog_id':xxx, 'timestamp':xxx, 'title':xxx, 'content':xxx } As the…
Tacaza
  • 539
  • 1
  • 4
  • 12