Stack Exchange Network

Stack Exchange network consists of 174 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.

2
votes
1answer
42 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
139 views

Picking/Selecting in an association

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

Ranking polynomials based on global maxima

Suppose I have the following polynomials in an association i.e. <|...|>, they are: ...
0
votes
4answers
102 views
5
votes
2answers
88 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
149 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
89 views

Delete zeros from a sparse array [duplicate]

Why doesn't SparseArray automatically remove zero entries? The code ...
6
votes
0answers
48 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
294 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
154 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
75 views

Merge Associations and replace absent value with 0

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

KeySelect via Not[StringMatchQ[Pattern]] fails

I have an Association asc that has mixed type Keys: ...
0
votes
1answer
107 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 ...
5
votes
1answer
57 views

unexpected result from augmented assignment to association

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

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

Bug introduced in 10.0.2 or earlier and persisting through 11.3 Confirmed: CASE:4041910 Consider the following example: ...
4
votes
1answer
162 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
88 views

speedy update of list of associations

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

Convert List of Associations into Association of Lists

For neural networks mathematica likes 2 ways to structure training sets: ...
3
votes
2answers
126 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
77 views

GraphDistance error when Graph vertices are Associations

Bug introduced in 10.0 or earlier and persisting through 11.3 Here is a nice graph whose vertices are Associations: ...
2
votes
1answer
50 views

Filter rows in nested Association / Dataset using Select

The Dataset I am working with has the following nested structure. ...
1
vote
1answer
69 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
104 views

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

I expected that something like this ...
6
votes
1answer
81 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
188 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
234 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
176 views

ByteCount on Function

I was comparing RAM and CPU efficiency for List, Rule, Association, Function. The following code ...
1
vote
1answer
123 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
115 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
27 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
123 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
66 views

List of Strings to Associations [closed]

I have a list of Strings, some thing like below: ...
6
votes
1answer
87 views

How to update values of particular keys efficiently

Say I have a list of Association, SeedRandom[45] test = Association[Table[i -> RandomInteger[30], {i, 6}]] <|1 -> 18, ...
1
vote
1answer
43 views

How to draw DensityPlot on a given association? [closed]

I want to draw a DensityPlot similar to below:- DensityPlot[Sin[x] Sin[y], {x, -4, 4}, {y, -3, 3}] But my problem is, I am not given the function itself. I am ...
5
votes
1answer
100 views

Replace value in association data-set

I have an association dataset with a depth of two (each value is an association too, and the size of the dataset ~ 30000 keys and an average size of values are ~2000 keys association). The dataset ...
1
vote
1answer
48 views

Selecting nonzero rules from a list

I have a list of rules: list = {a1 -> 0, a2 -> 3x, a4 -> 0, a5 -> 5x+3...}. I would like to append to another list the nonzero rules, which are: ...
1
vote
1answer
34 views

Get values of Dataset in depth 2

Given the following dataset ...
3
votes
1answer
69 views

A calculation in two depth association

I have a dataset where values are associations too. ...
1
vote
1answer
73 views

Why do I need a second Function in SortBy for Association?

I cannot understand why I need a second pure function when trying to sort Association by Key. Here is an example ...
3
votes
1answer
95 views

Associations & generating training sets

Solution: Pi is allowed in training sets, but not in batches generated by the batch generating function preamble: I want to generate my own batches of training data for training a deep CNN. ref/...
2
votes
0answers
26 views

Keyed eigensystem for nested Association

Suppose a matrix is given where both rows and columns are keyed, for example this correlation matrix: ...
1
vote
1answer
35 views

Button doesn't work with Append [duplicate]

I have a extremely simple question on Button. I tried to append values to associations. The Append works good with given value outside button, but once it is inside Button, it doesn't append the value ...
2
votes
1answer
47 views

Handling Missing values flexibly in Query (MissingBehavior problem)

There’s an inconsistency in how Missing values are imputed in Query, with ...
6
votes
2answers
167 views

Average length (in words) of paragraphs in document

I try to calculate the average length (in words) of paragraphs in a document. The data look like: ...
0
votes
0answers
52 views
2
votes
0answers
67 views

Lookup in Association [closed]

I have some issues with the Lookup in Association. My association looks as: ...
1
vote
1answer
89 views

Dynamically update of Association

I try dynamically to add new keys and update the values of existing keys in given dataset (Association). I implement this by the following code: ...