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
21
votes
6 answers

Java stream group by and sum multiple fields

I have a List fooList class Foo { private String category; private int amount; private int price; ... constructor, getters & setters } I would like to group by category and then sum amount aswell as price. The result will be stored…
MatMat
  • 878
  • 3
  • 8
  • 24
21
votes
8 answers

LINQ query — Data aggregation (group adjacent)

Let's take a class called Cls: public class Cls { public int SequenceNumber { get; set; } public int Value { get; set; } } Now, let's populate some collection with following elements: Sequence Number Value ======== ===== 1 …
Dariusz Woźniak
  • 9,640
  • 6
  • 60
  • 73
20
votes
3 answers

Split a list of tuples into sub-lists of the same tuple field

I have a huge list of tuples in this format. The second field of the each tuple is the category field. [(1, 'A', 'foo'), (2, 'A', 'bar'), (100, 'A', 'foo-bar'), ('xx', 'B', 'foobar'), ('yy', 'B', 'foo'), (1000, 'C', 'py'), …
Kaung Htet
  • 577
  • 1
  • 11
  • 28
20
votes
4 answers

How to filter array of objects in react native?

I want to filter this data array into state and city array. How can I achieve this using lodash or any other better way rather than for loop and maintaining extra arrays. data: [ { id: 1, name: Mike, city: philps, state: New York}, { id: 2,…
Balasubramanian
  • 5,274
  • 6
  • 33
  • 62
19
votes
2 answers

A way to group table cells together in html?

So it is pretty straight forward. I need a way to group cells together. Like a
or a but none of them worked. seemed like a good solution but it only works for table rows. Help!
Allen Hundley
  • 221
  • 1
  • 2
  • 4
19
votes
5 answers

How to groupBy object properties and map to another object using Java 8 Streams?

Suppose I have a group of bumper cars, which have a size, a color and an identifier ("car code") on their sides. class BumperCar { int size; String color; String carCode; } Now I need to map the bumper cars to a List of DistGroup…
MC Emperor
  • 22,334
  • 15
  • 80
  • 130
19
votes
2 answers

Parsing JSON record-per-line with jq?

I've got a tool that outputs a JSON record on each line, and I'd like to process it with jq. The output looks something like…
Roger Lipscombe
  • 89,048
  • 55
  • 235
  • 380
19
votes
1 answer

Grouping JSON by values

Using the Lever job posting API, I'm getting JSON results sorted by location, and I'm trying to figure out how to group all those results by "team" within the results, like the Shopify careers page. Here is the codepen and here is the JSON I tried…
robotsmeller
  • 345
  • 2
  • 4
  • 13
19
votes
3 answers

GroupBy on complex object (e.g. List)

Using GroupBy() and Count() > 1 I'm trying to find duplicate instances of my class in a list. The class looks like this: public class SampleObject { public string Id; public IEnumerable Events; } And this is how I instantiate and…
Jake Manet
  • 1,174
  • 3
  • 15
  • 26
19
votes
4 answers

Limit groupBy in Java 8

How can I limit groupBy by each entry? For example (based on this example: stream groupBy): studentClasses.add(new StudentClass("Kumar", 101, "Intro to Web")); studentClasses.add(new StudentClass("White", 102, "Advanced…
yossico
  • 3,421
  • 5
  • 41
  • 76
19
votes
1 answer

Javascript json data grouping

Sorry if this has been asked before, but I couldn't find a good example of what I'm trying to accomplish. Maybe I'm just not searching for the right thing. Please correct me if there's an explanation of this somewhere. Anyway... I have JSON data…
ksumarine
  • 782
  • 2
  • 12
  • 33
18
votes
4 answers

Regroup column values in a pandas df

I have a script that assigns a value based off two columns in a pandas df. The code below is able to implement the 1st step but I'm struggling with the second. So the script should initially: 1) Assign a Person for each individual string in [Area]…
user9394674
18
votes
4 answers

Pandas: df.groupby() is too slow for big data set. Any alternatives methods?

I have a pandas.DataFrame with 3.8 Million rows and one column, and I'm trying to group them by index. The index is the customer ID. I want to group the qty_liter by the index: df = df.groupby(df.index).sum() But it takes forever to finish the…
Elsa Li
  • 673
  • 3
  • 9
  • 19
18
votes
2 answers

Manually chain GroupBy collectors

I want to group a list of person's. A person have some attributes like name, country, town, zipcode, etc. I wrote the static code, which works very well: Object groupedData = data.stream().collect(groupingBy(Person::getName,…
Thomas Z.
  • 566
  • 6
  • 21
18
votes
3 answers

Pandas: remove group from the data when a value in the group meets a required condition

I have groupings of values in the data and within each group, I would like to check if a value within the group is below 8. If this condition is met, the entire group is removed from the data set. Please note the value I'm referring to lies in…
nrcjea001
  • 1,027
  • 1
  • 9
  • 21