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
14
votes
1 answer

How to show row count in SSRS per grouping on variable group-by value?

Essentially, I'd like to have separate row counts per grouping. I believe I'm supposed to use RowNumber. This seems to have been discussed but I'm having difficulty due to the fact that my groupby is not a string constant. My attempts have lead to…
D'Arcy Rail-Ip
  • 11,505
  • 11
  • 42
  • 67
14
votes
4 answers

Group row data by one column value and populate a subarray in each group with the other column value

I want to group the data in an array with associative rows. Group should be determined by the type value and all label_id values within each group should be formed into a subarray. Sample input: $array = [ ['type' => 'AAA', 'label_id' =>…
408
  • 161
  • 1
  • 1
  • 4
13
votes
5 answers

Group rows in a 2d array and count number of rows in each respective group

I have an array of 200 items. I would like to output the array but group the items with a common value. Similar to SQL's GROUP BY method. This should be relatively easy to do but I also need a count for the group items. Does anyone have an efficient…
GivP
  • 2,634
  • 6
  • 32
  • 34
13
votes
1 answer

Columns are collapsed when using group in datagrid

I have a datagrid in which I display several objects with some columns. I added grouping to the datagrid and now it seems that it doens't like the colulmns with width of '*' - the columns are all collapsed to their minimum widths. However, when I…
David Brunelle
  • 6,528
  • 11
  • 64
  • 104
13
votes
3 answers

How to group DataGrid Column Headers in WPF

Is it possible to do this in a WPF datagrid : |-------------- A header------------|---------------B Header---------------| |-----A1Header----|----A2Header-----|-----B1Header-----|-----B2Header------| |-----A1Data------|----A2 Data------|-----B1…
David Brunelle
  • 6,528
  • 11
  • 64
  • 104
13
votes
1 answer

Java Streams: Replacing groupingBy and reducing by toMap

I've asked a question before about enhancing some code, here. @Holger gives me the right response and he said that: Whenever you find yourself using the reducing collector with groupingBy, you should check whether toMap isn’t more appropriate It…
bubbles
  • 2,597
  • 1
  • 15
  • 40
13
votes
2 answers

How to get a custom type instead of Integer when using Collectors.summingInt?

I am currently creating a Map> like this, where the Integer represents seconds: Map> map = stream.collect(Collectors.groupingBy( x -> x.getProject(), …
Alex78191
  • 2,383
  • 2
  • 17
  • 24
13
votes
3 answers

Running total by grouped records in table

I have a table like this (Oracle, 10) Account Bookdate Amount 1 20080101 100 1 20080102 101 2 20080102 200 1 20080103 -200 ... What I need is new table grouped by Account…
Zsolt Botykai
  • 50,406
  • 14
  • 85
  • 110
13
votes
2 answers

Is there an accumarray() that takes matrix as `val`?

accumarray()'s val argument must be a vector. In my case I need columns of a matrix to be summed (or averaged). Is there a function or a method to achieve this? What I am doing now is in a for loop I am summing column values separately: for iCol =…
nimcap
  • 10,062
  • 15
  • 61
  • 69
13
votes
2 answers

How to group a set of objects into sorted lists using java 8?

I want to take a set of objects (ObjectInstance in this case), and I want to group them by one property, and have the resulting lists be sorted on another. Set beans = server.queryMBeans(null, null); Map>…
Ken DeLong
  • 341
  • 2
  • 5
  • 16
13
votes
2 answers

In C#, what is the best way to group consecutive dates in a list?

I have a list of dates and I want to group by items that are consecutive days so if in the list I have the following dates: Dec 31, 2013 Jan 1, 2014 Jan 2, 2014 Feb 1, 2014 Feb 2, 2014 Feb 16, 2014 Mar 13, 2014 I want to come up with a way to…
leora
  • 188,729
  • 360
  • 878
  • 1,366
13
votes
2 answers

Assigning values in first rows of groups in a data.table

I'd like to assign only those values in the first row of a group in a data.table. For example (simplified): my data.table is DT with the following content x v 1 1 2 2 2 3 3 4 3 5 3 6 The key of DT is x. I want to address every first…
MDS
  • 133
  • 5
13
votes
2 answers

ggplot2: group x axis discrete values into subgroups

I would like to create a bar plot with ggplot2 in which the discrete values of the x axis would be grouped into subgroups (see picture attached - the picture is from the web I do not have a code for the plot yet). Thanks for your help !
lqdo2000
  • 351
  • 2
  • 5
  • 16
13
votes
6 answers

Group consecutive integers and tolerate gaps of 1

In Python, given a list of sorted integers, I would to group them by consecutive values and tolerate gaps of 1. For instance, given a list my_list: In [66]: my_list Out[66]: [0, 1, 2, 3, 5, 6, 10, 11, 15, 16, 18, 19, 20] I would like the following…
Ricky Robinson
  • 21,798
  • 42
  • 129
  • 185
13
votes
3 answers

R data.table grouping for lagged regression

table with data (its a data.table object) that looks like the following : date stock_id logret 1: 2011-01-01 1 0.001 2: 2011-01-02 1 0.003 3: 2011-01-03 1 0.005 4: 2011-01-04 1 0.007 5:…
user1480926
  • 634
  • 5
  • 12