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

Grouping elements of a list into sublists (maybe by using guava)

I want to group elements of a list. I'm currently doing it this way: public static List> group(final List list, final GroupFunction groupFunction) { List> result = Lists.newArrayList(); for (final E element :…
Fabian Zeindl
  • 5,860
  • 8
  • 54
  • 78
37
votes
4 answers

How to group android notifications like whatsapp?

I don´t know how to group two or more notifications into only one and show a message like "You have two new messages".
36
votes
3 answers

When to use GROUPING SETS, CUBE and ROLLUP

I have recently learned about GROUPING SETS, CUBE and ROLLUP for defining multiple grouping sets in sql server. What I am asking is under what circumstances do we use these features ? What are the benefits and advantages of using them? SELECT…
June
  • 974
  • 5
  • 20
  • 34
36
votes
8 answers

Group 2d array data using column value to create a 3d array

I have a multidimensional array and am trying to group them according to the value in a specific column. I'm trying to group them by level, but I won't actually know the level beforehand. So, it's not like I can put it in a for loop and say while…
n00b0101
  • 6,863
  • 17
  • 42
  • 36
34
votes
3 answers

JavaScript Group By Array

Possible Duplicate: array_count_values for javascript instead Let's say I have simple JavaScript array like the following: var array = ['Car', 'Car', 'Truck', 'Boat', 'Truck']; I want to group and count of each so I would expect a key/value map…
aherrick
  • 19,799
  • 33
  • 112
  • 188
31
votes
5 answers

How to group dates by week?

I am writing an Excel exporter for a bespoke application I am creating, and I have a question about LINQ grouping in C#. Basically, this new Excel exporter class is given two dates. The class then retrieves all consignments between this date…
Chris
  • 7,415
  • 21
  • 98
  • 190
31
votes
7 answers

Oracle: How to count null and non-null rows

I have a table with two columns that might be null (as well as some other columns). I would like to count how many rows that have column a, b, both and neither columns set to null. Is this possible with Oracle in one query? Or would I have to create…
Svish
  • 152,914
  • 173
  • 462
  • 620
31
votes
4 answers

Mongodb aggregation pipeline how to limit a group push

I am not able to limit the amount of pushed elements in a group function with aggregation pipeline. Is this possible? Small example: Data: [ { "submitted": date, "loc": { "lng": 13.739251, "lat": 51.049893 }, "name":…
chaosbohne
  • 2,454
  • 2
  • 22
  • 27
31
votes
8 answers

Grouping Python tuple list

I have a list of (label, count) tuples like this: [('grape', 100), ('grape', 3), ('apple', 15), ('apple', 10), ('apple', 4), ('banana', 3)] From that I want to sum all values with the same label (same labels always adjacent) and return a list in…
hoju
  • 28,392
  • 37
  • 134
  • 178
30
votes
1 answer

How to generate a train-test-split based on a group id?

I have the following data: pd.DataFrame({'Group_ID':[1,1,1,2,2,2,3,4,5,5], 'Item_id':[1,2,3,4,5,6,7,8,9,10], 'Target': [0,0,1,0,1,1,0,0,0,1]}) Group_ID Item_id Target 0 1 1 0 1 1 2 0 2 …
30
votes
7 answers

Creating sublists

The opposite of list flattening. Given a list and a length n return a list of sub lists of length n. def sublist(lst, n): sub=[] ; result=[] for i in lst: sub+=[i] if len(sub)==n: result+=[sub] ; sub=[] if sub:…
Michael Puckett
  • 465
  • 1
  • 5
  • 7
30
votes
5 answers

Group and count with condition

I'm trying to group a set of documents and count them based on their value: { item: "abc1", value: 1 } { item: "abc1", value: 1 } { item: "abc1", value: 11 } { item: "xyz1", value: 2 } I would like to group by item and get in return a count of how…
maephisto
  • 4,952
  • 11
  • 53
  • 73
29
votes
5 answers

Rails has_many association count child rows

What is the "rails way" to efficiently grab all rows of a parent table along with a count of the number of children each row has? I don't want to use counter_cache as I want to run these counts based on some time conditions. The cliche blog…
SWR
  • 667
  • 2
  • 6
  • 12
29
votes
3 answers

Create range bins from SQL Server table for histograms

I have the following table in SQL Server: ----------------------------- ID Age Gender 1 30 F 2 35 M 3 32 M 4 18 F 5 21 F What I need to do…
user10901
  • 629
  • 1
  • 8
  • 16
28
votes
3 answers

Angular Material mat-table Row Grouping

Leaving aside the libraries that provide row grouping for their particular tables, I am trying to implement such a feature on Angular Material 2 mat-table which does not come with such a feature. Items to populate the table: export class…
Vlad Danila
  • 1,222
  • 3
  • 18
  • 38