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
18
votes
4 answers

Grouping by object value, counting and then setting group key by maximum object attribute

I have managed to write a solution using Java 8 Streams API that first groups a list of object Route by its value and then counts the number of objects in each group. It returns a mapping Route -> Long. Here is the code: Map
Jernej Jerin
  • 3,179
  • 9
  • 37
  • 53
17
votes
3 answers

Combine two dictionaries with preference to one of them -

I have two dictionaries One: default = {"val1": 10, "val2": 20, "val3": 30, "val4": 40} Two: parsed = {"val1": 60, "val2": 50} Now, I want to combine these two dictionaries in such a way that values for the keys present in both the dictionaries…
Rohan Asokan
  • 634
  • 4
  • 22
17
votes
7 answers

Group by field name in Java

I'm trying to group Java objects by their field, i.e Person.java public class Person { String name; String surname; .... } So if I have n Person objects, what would be the easiest way to get all people name "David" into a map like…
London
  • 14,986
  • 35
  • 106
  • 147
17
votes
3 answers

Trying to optimise fuzzy matching

I have 2,500,000 product names and I want to try and group them together, i.e. find products that have similar names. For example, I could have three products: Heinz Baked Beans 400g; Hz Bkd Beans 400g; Heinz Beans 400g. that are actually the…
Richard Hansell
  • 5,315
  • 1
  • 16
  • 35
17
votes
6 answers

"Grouping" dictionary by value

I have a dictionary: Dictionary. I want to get new dictionary where keys of original dictionary represent as List. This is what I mean: var prices = new Dictionary(); The prices contain the following data: 1 100 2 200 3 …
user1260827
  • 1,498
  • 6
  • 31
  • 53
16
votes
2 answers

LINQ Conditional Group

Is it possible to write a LINQ statement with a conditional group clause? Here is basically what I'm trying to do: bool someFlag = false; var result = from t in tableName group t by new { (someFlag ? 0 : t.FieldA), t.FieldB } into g select…
MrDustpan
  • 5,508
  • 6
  • 34
  • 39
16
votes
3 answers

SlickGrid Column Groups

Is there a way to add a column groupings? For example: Unit 1 | Unit 2 | Pre Mid Post | Pre Mid Post | --- --- ---- | --- --- ---- | 2 4 5 | 3 4 4 | 1 2 4 | 3 4 5 | Basically, I need a header row for Unit…
Varmint
  • 161
  • 1
  • 4
16
votes
1 answer

Pandas - group by column and transform the data to numpy array

Having the following data frame, group A have 4 samples, B 3 samples and C 1 sample: group data_1 data_2 0 A 1 4 1 A 2 5 2 A 3 6 3 A 4 7 4 B 1 4 5 B …
Shlomi Schwartz
  • 8,693
  • 29
  • 109
  • 186
16
votes
2 answers

Fill and dodge boxplots by group on a continuous x axis

I have been having issues with what seems to be a simple thing to do: grouped boxplots with a continuous x axis. Here is come minimal data data: df <- cbind(expand.grid(x=1:10, rep=1:20, fill=c("A", "B")), y=runif(400)) And here is what I want; …
NWaters
  • 1,163
  • 1
  • 15
  • 27
16
votes
3 answers

How can I hierarchically group data using LINQ?

I have some data that has various attributes and I want to hierarchically group that data. For example: public class Data { public string A { get; set; } public string B { get; set; } public string C { get; set; } } I would want this…
Jeff Yates
  • 61,417
  • 20
  • 137
  • 189
15
votes
3 answers

Show all possible groupings of a list, given only the amount of sublists (lengths are variable)

Problem Step 1: Given a list of numbers, generate all possible groupings (in order) given only the final number of desired groups. For example, if my list of numbers were 1 to 4, and I wanted 2 final groups, the possibilities would be: [1],…
Brett Woodward
  • 323
  • 3
  • 12
15
votes
2 answers

Pandas group the rows in a dataframe based on specific column value

I have the data frame as like below one, Input DataFrame gw_mac mac 0 ac233fc015f6 dce83f3bc820 1 ac233fc015f6 ac233f264a4c 2 ac233fc015f6 ac233f264a4c 3 ac233fc015f6 …
Mahamutha M
  • 1,235
  • 1
  • 8
  • 24
15
votes
1 answer

LINQ: grouping based on property in sublist

I'am trying to use LINQ to create a grouped list of documents based on metadata which is a list on the document. Below is how my object structure looks: List --> List --> Metadata has a name and a…
ChristiaanV
  • 5,401
  • 3
  • 32
  • 42
15
votes
2 answers

Java Streams: get values grouped by inner map key

I have Map> and I want to get Map> from it using Java Streams. I try to do it as follows: public Map> groupsByInnerKey(Map> input) { return input.values() .stream() …
hotkey
  • 140,743
  • 39
  • 371
  • 326
15
votes
2 answers

Group list by month

I have list with datetime objects. I would like to group by month and add it to the dictionary. So after grouping process I want to have list per month and year. For example: Before grouping [mix below elements] After grouping: 1) January 2015 - 5…
mskuratowski
  • 4,014
  • 15
  • 58
  • 109