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
2
votes
5 answers

How to sum array value of duplicate data

I have an array with some of same ID value as shown in below. [ {"ID":"126871","total":"200.00","currency":"USD","name":"John"}, {"ID":"126872","total":"2000.00","currency":"Euro","name":"John"}, …
Cloud
  • 1,004
  • 1
  • 18
  • 47
2
votes
3 answers

Javascript arrays: group by unique values and sum-up amount per value

I'm trying to build my own app, and I'm stuck at one issue that I cannot solve. My app deals with mortgages. I have several mortgages running in parallel, and I just need to sum-up total payments per period. Let's say that we have the following…
nadir
  • 1,223
  • 4
  • 12
  • 21
2
votes
4 answers

SQL: Expand 1 Column into 3 on Summarize Table

I'm writing a program that displays products and the stores at which they can be located. So far, I've been able to write an SQL query that displays data as follows: Product Availability Milk Store1 Candy Store1 Eggs Store1 Milk …
Alex Essilfie
  • 12,339
  • 9
  • 70
  • 108
2
votes
1 answer

fabricJS - Cloning objects to another canvas goes wrong when selecting multiple objects

I have two canvas layer, stacked on each other. A top layer named top and a bottom layer named bottom. On the top layer I add some objects that are transparent and only show their handles. The bottom layer should clone the objects from the top,…
Fidel90
  • 1,828
  • 6
  • 27
  • 63
2
votes
1 answer

rails, group for average and then group again for sum

Example: a table, in which the power consumption is saved every few minutes. What i am trying to do with this data using the groupdate gem: @kWh = Consumption.group_by_hour(:at).average(:kw) @kWh_per_day =…
tuvya
  • 21
  • 4
2
votes
1 answer

PHP Nested Array 'Mesh Like' Grouping

I'm having a few issues writing accurate and efficient code in PHP for this problem below. I have a list of users, and each user has a list of friends. I want to group all the friends into groups where each person has at least one friend with…
mt025
  • 273
  • 4
  • 13
2
votes
1 answer

lodash chaining groupBy

I'm trying to figure out how to convert an array of vehicle objects, that are only unique by trim/year, to an array nested object properties. Originally I was looping through all of the properties to organize the vehicles into a hierarchical…
neridaj
  • 2,143
  • 9
  • 31
  • 62
2
votes
2 answers

A special case of grouping coordinates

I'm trying to write a program to place students in cars for carpooling to an event. I have the addresses for each student, and can geocode each address to get coordinates (the addresses are close enough that I can simply use euclidean distances…
dlras2
  • 8,416
  • 7
  • 51
  • 90
2
votes
3 answers

SQL Server Determine Most Occurances Of Data In A Group

Let's say I have the following: COL1 COL2 COL3 ABC DATA1 ABC DATA1 ABC DATA2 ABC DATA3 DEF INFO1 DEF INFO2 DEF INFO3 DEF INFO3 I want to use SQL to propagate the…
MichaelTFL
  • 21
  • 2
2
votes
1 answer

SQL Server - WHERE Date Range & GROUP BY MonthName

I have 2 same queries (to return "MonthName Year" and count) as below, but only the date range in the WHERE condition is different. Query 1 gets only the June month count, while Query 2 gets count from Apr to Jul, where the Jun month count (in Query…
2
votes
4 answers

JAVASCRIPT reorder an array by group of consecutive values

I'm looking for a way to reorder an array by a set of consecutive fixed values. For example: I have got an array of items: items = [ {id: 1, name: "Test 1", group: 1}, {id: 2, name: "Test 2", group: 2}, {id: 3, name: "Test 3", group: 2}, …
2
votes
1 answer

Doing calculations on Pandas DataFrame with groupby and then passing it back into a DataFrame?

I have a data frame that I want to group by two variables, and then perform calculation within those variables. Is there any easy way to do this and put the information BACK into a DataFrame when I'm done, i.e. like…
user1566200
  • 1,826
  • 4
  • 27
  • 47
2
votes
1 answer

Split Python Dataframe into multiple Dataframes (where chosen rows are the same)

I would like to split one DataFrame into N Dataframes based on columns X and Z where they are the same (as eachother by column value). For example, this input: df = NAME X Y Z Other 0 a 1 1 1 1 1 b 1 1 2 2 2 c 1 2 1 3 3 d 1 2 2…
birdmw
  • 865
  • 10
  • 18
2
votes
1 answer

Using groupby() together with filter in list comprehensions

Why is it that >>> [ ( { k: len(list(g)) } ) for k, g in groupby(sorted('ABABAABBAC')) ] [{'A': 5}, {'B': 4}, {'C': 1}] but >>> [ ( { k: len(list(g)) } ) for k, g in groupby(sorted('ABABAABBAC')) if len(list(g)) > 1 ] [{'A': 0}, {'B': 0}] It…
laurids
  • 931
  • 9
  • 24
2
votes
1 answer

Group rectangles in a grid

I have a randomly-sliced rectangular grid - width is 80 unit. I already have the free spaces of each row of my grid stored in an array like this below: [ {pX:1,sX:15}, {pX:30,sX:13}, {pX:43,sX:1}, {pX:44,sX:17} ], [ …
deblocker
  • 7,629
  • 2
  • 24
  • 59
1 2 3
99
100