Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [associations]

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

1
vote
2answers
59 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
116 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
59 views

Create Dataset from lists

Let's assume I created the following dataset: ...
2
votes
1answer
31 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 ...
3
votes
0answers
62 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
59 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
44 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
52 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
65 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
207 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
64 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
37 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
106 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
556 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
225 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
53 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
157 views

Picking/Selecting in an association

suppose I have 2 associations t1=<|"a" -> 1, "b" -> 2, "c" -> 3, "d" -> 4|> and ...
5
votes
1answer
97 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
326 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
42 views

Ranking polynomials based on global maxima

Suppose I have the following polynomials in an association i.e. <|...|>, they are: ...
0
votes
4answers
136 views
5
votes
2answers
98 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 ...
1
vote
1answer
201 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
127 views

Delete zeros from a sparse array [duplicate]

Why doesn't SparseArray automatically remove zero entries? The code ...
7
votes
0answers
61 views

Substitute for Association inside Compile?

Associations are not compilable, so I’m looking for a workaround to this. That is, I need a mutable hashtable-like data structure with fast key value lookups ...
10
votes
3answers
314 views

Min and Max of a list of Associations

I am trying to find the minimum values for all elements in a list of associations, below is an example ...
3
votes
2answers
201 views

Iterate over keys of association

How do you iterate over the keys or rules of an association (in any order)? E.g. for <|"0"->"a", "1"->"b", "2"->"c"|> I would like to either ...
2
votes
3answers
89 views

Merge Associations and replace absent value with 0

I have two associations like this ...
3
votes
1answer
46 views

KeySelect via Not[StringMatchQ[Pattern]] fails

I have an Association asc that has mixed type Keys: ...
0
votes
1answer
127 views

Aggregate function problem

I use a function to do something similar to a SQL sum. I've asked about simplifying it in another post. I'm still using this function and it works well for aggregates like ...
6
votes
1answer
64 views

unexpected result from augmented assignment to association

Is the last of these results expected? If so, how? ...
10
votes
1answer
98 views

Parallelize[MapIndexed[…,Association[…]]] returns broken result

Bug introduced in 10.0.2 or earlier and persisting through 12.0 Confirmed: CASE:4041910 Consider the following example: ...
5
votes
1answer
222 views

Parallelize the construction of sparse matrices

I'm trying to parallelize a few constructions of chain complexes (given as a list of sparse matrices). I have a function that for any column (or row) computes the list of nonzero entries in that ...
1
vote
0answers
39 views

Extracting Parts of Speech

I am looking to parse the ConstituentsTree from TextStructure. Someone already asked how to get the proper nouns out of a text here: Extract names from a document I am looking for a more general ...
4
votes
2answers
91 views

speedy update of list of associations

Suppose as is a list of associations that I want to update. For example: ...
12
votes
3answers
298 views

Convert List of Associations into Association of Lists

For neural networks mathematica likes 2 ways to structure training sets: ...
3
votes
2answers
131 views

Merge associations with the same keys, same in a sense by user's definition

I know that it is the standard functionality of Merge to combine the values of the same keys among associations. Now I would like to deal with a situation in which,...
6
votes
2answers
101 views

GraphDistance error when Graph vertices are Associations

Bug introduced in 10.0 or earlier and fixed in 12.0 Note: Associations are new in 10.0 Here is a nice graph whose vertices are Associations: ...
2
votes
1answer
70 views

Filter rows in nested Association / Dataset using Select

The Dataset I am working with has the following nested structure. ...
1
vote
1answer
85 views

Converting a list of associations into a single association

How do i smartly join a List of Associations (eg. returned by ParallelTable) such that i get a single Association? ...
6
votes
2answers
121 views

How to use ReplaceAll and RuleDelayed with an Association? [duplicate]

I expected that something like this ...
6
votes
1answer
88 views

How can I update an association with a function?

I'm not sure if this is a bug, or if I just am not understanding, properly, how to create a function. I am able to use a list of rules to update an association like so: ...
7
votes
2answers
211 views

How can I map associations to expressions?

I have a list of associations, and I would like to make it so that an expression automatically reads the associated data from the associations list, that has the same name, into the expression. An ...
8
votes
2answers
245 views

Deleting all keys that have null values

I have a notebook that I am working on that starts with an imported CSV file. Many of the rows have blank data in them. I have used the following command to establish a list of associations: ...
5
votes
3answers
179 views

ByteCount on Function

I was comparing RAM and CPU efficiency for List, Rule, Association, Function. The following code ...
1
vote
1answer
129 views

How to make an Association of Assocations [closed]

As a learning exercise I’m trying to convert some data we have from spreadsheets into an association of associations. However, I’ve only managed to format two different associations, a key of the ...
11
votes
1answer
123 views

stable sort for association?

Should I be able to use the "list of functions" approach to getting a stable sort of an association? In 11.1 I see, ...
0
votes
1answer
44 views

how to get association from json? [closed]

How do I convert {{"a" : 13, "z" : 24},{"f" : 17, "h" : 94}} to get {{"a" -> 13, "z" -> 24},{"f" -> 17, "h" -> 94}} I am trying to change : to ->
3
votes
3answers
129 views

Simpler way to thread dataset values to each other

I have a relatively simple dataset that provides a list of values for a list of countries: ...
0
votes
1answer
72 views

List of Strings to Associations [closed]

I have a list of Strings, some thing like below: ...