Questions tagged [associations]

Questions on the associative data-structure introduced in Mathematica version 10.

Filter by
Sorted by
Tagged with
1
vote
0answers
40 views

Append columns to a Dataset without unpacking via Normal [duplicate]

I would consider myself transitioning from beginner to intermediate skill in Mathematica, and am finally exploring Associations and Datasets. I am using version 12. I have a Dataset (list of ...
0
votes
0answers
30 views

How to use Headers after imported them?

I read this post here, and played a bit with the Import function, so I now have my data imported from xlsx file, which say is a <...
4
votes
4answers
149 views

Change a list of associations by applying a function to specific keys?

If I have a list of associations (listAssoc) with members all having key someKey, how can I generate a new list of associations <...
13
votes
3answers
264 views

How to make arbitrary transpositions of associations and datasets

Is there a general Transpose for Dataset/Association that will transpose arbitrary levels, ...
19
votes
4answers
1k views

Merge function performing too slowly; what can be done about it?

I have an extremely large CSV file that contains only entries like the following: ...
2
votes
0answers
40 views

KeyUnion by equivalent patterns

I have associations whose keys are patterns. For example, ass1 = <|a_ -> 1, f[] -> 3|>; ass2 = <|b_ -> 2|>; I would like to construct the ...
5
votes
1answer
68 views

Summing Values in an “Association” with the same Keys

I have a datastructure which is similar to an association: However, it has duplicate "keys" (different entries with the same date) with different values (measured in hours). What I'd like do is ...
3
votes
2answers
81 views

Adding together values from different association lists

I have two association lists, whose values are integers, sharing some but not all keys. For a small example, we might have ...
5
votes
1answer
84 views

Apply a function over Dataset as if it's an Association

Take a list of Associations. Using the Dataset function, this can be converted to a structured dataset. ...
2
votes
0answers
39 views

Convert Key to Value in Dataset with nested Associations [duplicate]

Let's say I have a Dataset consisting of nested Associations (in this case, created through a ...
2
votes
1answer
32 views

Create an Association with Key->Value dependent on a previous Key->Value

I am trying to find a way to create an association (preferably without iterating) with values dependent on other values in the association. I know that this is incorrect, but an attempt that I've ...
10
votes
1answer
163 views

Reversing a GroupBy operation

Suppose that I have a this list of associations ...
6
votes
1answer
89 views

How to use a function as a value in an association? [closed]

I just started learning Mathematica. I was wondering if it is possible to use a function as an value in an association. Ideally, it would be something like this: ...
2
votes
2answers
55 views

How to associate the elements of a list to numbers?

I am having problems to understand the association function. I have a list of lists containing numbers: ...
8
votes
2answers
178 views

Taking the first element in a list of associations

I have the following list which is built up of associations, that is, ...
5
votes
3answers
83 views

Sort Associations by its Values (which are nested lists)

I have associations where the values are nested lists: ...
14
votes
3answers
283 views

Evaluated vs. unevaluated Association

This question might have a remote connection to my older question, it is also about sameness of expressions and subtle differences observable only in certain forms. I encountered this strange ...
3
votes
1answer
85 views

Edit value in nested Association

Here is a simplified version of my problem. I have a nested Association. ...
5
votes
3answers
295 views

Changing Row Keys into Normal Rows

I have a dataset with column and row keys: ...
6
votes
2answers
124 views

How to define a functional that produces at runtime a function by evaluating selected parts in its definition?

Consider the following functional as an example: ...
3
votes
2answers
75 views

Row Keys in Datasets: JoinAcross row keys; Demoting or deleting row keys

I want to combine two datasets that share row keys but have different column keys. Visually, this looks like a JoinAcross on the row keys to me, but the column of row keys doesn't appear to be named. ...
7
votes
2answers
101 views

Creating a new Dataset column using a map from a second Dataset

Say I have two datasets: one is a detailed list of events, and one is a coarse list of events. I want to add a column to the detailed list from the coarse list (for the purposes of sorting). For ...
11
votes
3answers
306 views

Move the outer key inward in an association

I have a list that looks like: ...
0
votes
0answers
26 views

Having trouble distributing a large association to sub-kernels

The following seems to work based on memory usage. ...
5
votes
3answers
238 views

Iterate over deepest values in a nested Association

Is it possible to iterate over the values of the deepest layer of keys in a nested association? For example: ...
1
vote
0answers
49 views

Wrapping an association with a specialization of the buildin `Set` (=) function?

I want to wrap some association data into a dedicated symbol (S by example) ...
1
vote
2answers
75 views

How to use KeyValuePattern with individual replacement rules?

What's the syntax to use individual replacement rules for key-value patterns? This returns only the first match: ...
4
votes
4answers
135 views

Neat redistribution of association values

Given an original association: original = <| "a" -> {a1, a2}, "b" -> {b1, b2}, "c" -> {c1, c2} |> and a set of redistribution rules e.g. <...
1
vote
2answers
89 views

Create Dataset from lists

Let's assume I created the following dataset: ...
2
votes
1answer
39 views

Hierarchically adding {…keys..}->value to an association

Given a list of keys {"a","b","c"} and a value 3 (associated to the last key) I want to define a function that is equivalent to ...
4
votes
1answer
119 views

Get Windows registry into Mathematica as an association

Windows probably is the only operating system that has a separate database of configuration instructions and paths. The windows registry looks exactly like a giant nested association. Also probably is ...
4
votes
1answer
69 views

Inconsistency in getting Keys, Values and Query for nested Rules

Querying nested Rule expressions of the form a -> v -> b // FullForm Rule[a,Rule[v,b]] for ...
2
votes
1answer
51 views

Turns nested Lists into nested Associations, ReplaceAll for list vs ReplacsAll for association

I want to transform some nested lists into nested associations except the "rows"->List pattern. Here is the example ...
1
vote
1answer
57 views

Sorting each column in a nested list contained in an association

I have an Association which contains three arrays 200x1000x2. Each row m of a matrix denotes a different set of parameters, while each column n contains the outcomes of the function for a specific ...
0
votes
2answers
66 views

Association on a list [closed]

I have a dataset under this form : sentence = {sentence1, sentence2, sentence3,...} and a list of label : label = {1,2,3,4,5,6,7...} both have same length ! So I want to make an association ...
4
votes
1answer
216 views

Inexact numbers as keys in Association?

Can someone explain me how Mathematica's Associations behave with inexact numbers as keys: <| 0.22499999999999964` -> a |> [0.22499999999999965`] and <...
3
votes
1answer
72 views

Reducing boilerplate with associations

I'm looking for advice either on alternative ways to approach my problem in general, or specifically on meta-programming (which seems to me to be a way around this). In my work I have databases of ...
1
vote
0answers
44 views

How do I Select when the key of an association is a multi-word string [closed]

I have imported some survey responses into a Dataset. I now want to select those rows where the response to "participant type" == "Virtual". I discovered that this ...
2
votes
1answer
154 views

Deleting missing values from a dataset

I wanted to create a dataset of all UFO sightings in April of 2018. The AssociationThread doesn't want to work, because some of the entries are missing value, what ...
19
votes
4answers
582 views

Is it possible to avoid unpacking when merging Association?

For example, if we have assoc = AssociationThread[{1, 2, 3} -> RandomReal[1., {3, 10}]]; and ...
7
votes
3answers
249 views

Obtaining a matrix of complex values from associations giving the real and imaginary parts of each element?

I have a list of associations keyed by real and imaginary numbers, like so: ...
2
votes
1answer
56 views

Converting an expression with strings to an association

I have an expression which contains a bunch of strings and some complex valued numeric factors in front. A couple of summands might look like this: ...
4
votes
2answers
169 views

Picking/Selecting in an association

suppose I have 2 associations t1=<|"a" -> 1, "b" -> 2, "c" -> 3, "d" -> 4|> and ...
5
votes
1answer
98 views

Define an access by key ( structure[key] ) for a custom structure struct?

I have some "complicated" data that I want to encapsulate into a "struct": For instance (imagine that data have several fields): ...
7
votes
5answers
335 views

Unexpected behaviour of Nothing inside List inside Association

When evaluating the following input: <|a -> {c, d, e}|> /. d -> Nothing I get (expression 1): ...
3
votes
1answer
43 views

Ranking polynomials based on global maxima

Suppose I have the following polynomials in an association i.e. <|...|>, they are: ...
0
votes
4answers
153 views

Is there a way to order elements in an Association?

...
5
votes
2answers
106 views

How to prevent arguments UpValues from being used in selective functions

Ok, I know the simple answer is to set some form of Hold attribute to the function but bear with me for a bit while I explain my motivation and why that is not quite what I want. I have a collection ...
2
votes
1answer
230 views

Bottom-most left-most entries in a sparse array

I have a list bdrs of SparseArrays, which represent the boundary matrices of a chain complex $R^{d_0}\overset{\partial_1}{\...
4
votes
1answer
184 views

Delete zeros from a sparse array [duplicate]

Why doesn't SparseArray automatically remove zero entries? The code ...