Questions on gathering, grouping or clustering data based on certain criteria. This is to be used with primary tags such as list-manipulation, string-manipulation or similar tags, with the primary tag indicating the specific use case.

learn more… | top users | synonyms (1)

2
votes
2answers
73 views

Group Datasets and take minimum/maximum

Good Morning I have the following dataset: And I try to reach this output: key: only one row per key text: join all texts of the rows with the same key (but no duplicates) min: take the lowest ...
1
vote
2answers
55 views

Creating Association [duplicate]

I have provided a dataset bellow and I would like to store the data as an Association that I can query. Such that e.g. ...
3
votes
2answers
80 views

Problem with Custom Sort/Split/Gather

Please help me Sort/Split/Gather/Group(by) a set of symbolic expressions! (extreme TL;DR at bottom) I have a set of symbols (which represent 2-vectors in a plane, ultimately) and I want to ...
11
votes
6answers
431 views

Reshaping associations, generalization of GroupBy

Let's say we have a set a\of associations: ...
3
votes
2answers
87 views

Role of Accuracy in numerical evaluations, SplitBy vs GatherBy

This is a follow-up question to this question. I generated a list by substituting the results of a solve[] routine and set: ...
11
votes
3answers
313 views

Partition a list based on specific elements? Grab the sublists beginning with a certain marker elements

Say I have the list {{a}, {0, 2, 5}, {5, 4, 1}, {a}, {1, 1, 0}, {1, 4, 2}, {3, 3, 0}, {a}, {3, 2, 0}, {1, 4, 1}} I would like to make sublists of everything ...
8
votes
3answers
138 views

Grouping by total length of elements grouped

How might one split a list of irregularly-long sublists into groups, each of which is shorter than a specified length? For example, given the following input: ...
24
votes
3answers
442 views

How to organically build up nested associations?

Suppose I want to construct an association of associations, such as a list of people with attributes: ...
30
votes
2answers
601 views

GroupBy twice gives different results

Bug introduced in 7.0 or earlier and persisting through 10.4 or later It took me quite a lot of time to finally trace down to this strange output. I really don't know why. First, I create a list ...
6
votes
3answers
129 views

Grouping words by their differences

I'm a new guy here and I face a problem. I should pair the following words according to the rule: pair the words, that differ by max. 2 characters, like: ...
6
votes
2answers
370 views

Exception with GatherBy: gathering complex conjugates

I want to gather the complex-conjugates that are in a list, but with an exception: only if the imaginary part isn't zero. For example: ...
7
votes
2answers
153 views

Allocate amount A according to the distribution of amount B

I have a cost that varies by category and date. I also have the counts of each item type within each category and date. I want to distribute the cost to each of the item types. I'm trying to use ...
6
votes
2answers
162 views

Grouping the list of numbers that have common.

I am working on some simple problem. It is like puzzle.. Let's say I have some list input={{1,1},{1,2},{1,3},{2,3},{3,3},{4,4}} Which means 1 can go and back to ...
2
votes
3answers
145 views

Join nested lists based on first and last elements within each list

I have a nested list like this: test1 = {{1, 3}, {1, 4}, {1, 7}, {2, 1}, {3, 5}, {4, 1}, {5, 2}, {6, 1}, {7, 6}} I want to join the lists together depending on ...
1
vote
4answers
100 views

GatherBy output with given Shape

I would like to group items in a binary list according to some property like in the following simple example. ...
10
votes
4answers
282 views

Handy / flexible directory tree operations

Is there any shorter / more handy / more flexible way to get directory tree as a nested Rules/Associations list? I tried to incorporate ...
4
votes
2answers
91 views

Using GatherBy with a DataSet's header designation instead of First

Using the code, where ds is data formatted into a Dataset GroupBy[ds, First] // TableForm I get a table that I wanted, but I was wondering if I could somehow use ...
2
votes
5answers
163 views

GatherBy based on condition imposed on index variable

Excuse me. This might be user specific question but I need your help. I have an indexed data, where positive integers are used for indexing data. I am trying to group data putting condition on index ...
4
votes
2answers
127 views

How to sum values in the list that belongs to same week

I need to sum values that belongs to same week. For example, I have the list x with one column and n rows. Format: ...
3
votes
3answers
509 views

Partitioning time series

I have a time series dataset I'm trying to plot by Year: ...
8
votes
3answers
318 views

GroupBy a list of associations with their keys

How can I go from ...
12
votes
5answers
472 views

How would you efficiently implement BinListsBy?

Let's say I have a list like this: data = {{21, "Alice"}, {27, "Bob"}, {22, "Charles"}, {34, "Dora"}, {75, "Eliza"}} containing ages and names of persons. What I ...
0
votes
1answer
89 views

Sorting a table of vectors with weights [duplicate]

I'm trying to simplify a table, for instance {{1, {4, 2, 0}}, {4, {2, 4, 0}}, {-2, {3, 3, 0}}, {1, {3, 0, 3}}, {-3, {0, 4, 2}}} Here the first column is the ...
4
votes
5answers
294 views

Summarize a list of pairs / (Using GatherBy and Tally?)

Given a list of (frencuently repeated and unsorted) pairs {Mode, SubMode} I want to form the list ...
6
votes
3answers
526 views

Finding connected components in an array

I have an $w\times h$ array with non-negative integers. I wish to partition the set of coordinates $(c,r)$ with $1\leq c \leq w$ and $1\leq r \leq h$, in subsets, so that each subset corresponds to a ...
1
vote
1answer
315 views

Formatting plot of symmetric points differently to asymmetric points

From an array of numbers, I would like to determine (and then colour appropriately) which points are symmetric about a given axis (here, $x = 1/2$), and which are not. For example, form this: ...
14
votes
7answers
850 views