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
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

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

11
votes
1answer
78 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
16 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
87 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
62 views

List of Strings to Associations [closed]

I have a list of Strings, some thing like below: ...
5
votes
1answer
64 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
40 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
81 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
39 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
31 views

Get values of Dataset in depth 2

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

A calculation in two depth association

I have a dataset where values are associations too. ...
1
vote
1answer
65 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
84 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/...
1
vote
0answers
22 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
21 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
41 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
159 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
32 views
2
votes
0answers
55 views

Lookup in Association [closed]

I have some issues with the Lookup in Association. My association looks as: ...
1
vote
1answer
64 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: ...
2
votes
3answers
113 views

Using Association[] in an Immediate Function

I have an Association[] which is the result of an intensive computation. Its values include the variable x and I would like to ...
1
vote
2answers
84 views

Select several values in nested associations

I have nested associations like this: ...
1
vote
4answers
122 views

How can I create an Association from a multidimensional list of values and a list of keys?

Given a list of values such as vals = {{{{0., 633.25}, {642.96, 677.34}}, {{591.56, 632.45}, {634.9, 715.6}}}} and a list of "Dimensions" such as ...
1
vote
0answers
37 views

Create Association from Expression

I have a set of algebraic expressions of a certain form, and I would like to make them into Associations in a specified way. My expressions are formed of two heads, ...
2
votes
2answers
75 views

`ListPlot` with `Association` as input

It seems ListPlot will somehow drop the trailing list of Associations when the Association ...
0
votes
1answer
37 views

Flatten table into Association Thread where each cell is an association from its column and row header

Let's say I have a table in Mathematica like so: Where the first row is the header, and first column is also a header (similar to a multiplication table). ie S_AS_A = Es; S_BS_A = ss_sigma; The ...
4
votes
1answer
55 views

How can I get Merge to indicate missing values?

Say I have the following code: Merge[{<|"a" -> 1, "b" -> 2|>, <|"a" -> 2, "c" -> 3|>}, Identity] The output is: ...
8
votes
2answers
133 views

Timing: extracting from List VS extracting from Association

I was wondering, why is extracting from an Association slightly faster than extracting from a List? ...
2
votes
2answers
65 views

Building a replacement rule from a pattern, Assocation and RuleDelayed [duplicate]

I'm trying to create a function that builds a replacement rule from a given pattern and I have trouble understanding what's going wrong. After having written most of the question, I see that it got ...
5
votes
4answers
198 views

Fastest way to look up in a list of Associations

Given a list of associations tab where each association has keys {"name", "a", "b"}: ...
4
votes
2answers
142 views

Creating a large surjective dictionary without repeated elements?

I would like to have a surjective dictionary that saves the following associations ...
3
votes
4answers
72 views

Cross-Rearranging parts of nested lists inside list of associations

I have list of associations like this: ...
1
vote
1answer
51 views

Extracting the graph of Keys in nested Associations

Related to this q: Extract all Values from nested Association How to extract the direct graph of all Keys in nested Associations...
1
vote
0answers
55 views

`Transpose` nested `Association`

Say I have a nested Association like this one: ...
1
vote
1answer
45 views

Plotting an association key corresponding to the maximum value

I have an Association <|0->q^2, 1->2p q, 2->p^2|>, where q=1-p. I would like to plot the key (0, 1 or 2) ...
3
votes
1answer
58 views

Rename Keys in Nested Association

I am looking to expand this post, How can a key be renamed in an Association?. I would like a function that automatically replaces any and all keys with the rule. Here is what I have so far ...
3
votes
0answers
36 views

Missing values vanish from expressions with DateObject and slot-lookup?

Missing value vanishes when adding or subtracting DateObject but only when slot-lookup is used, in an Association query: Given ...
7
votes
1answer
73 views

Association lookup in sub-kernel seems slow

While developing a parallel version of some code, I noticed that looking up an item in an association seemed much slower than in the serial version of the code. To show the effect, I created the ...
5
votes
2answers
128 views

How to set parts of Associations “named with” SubValues

Parts of Associations can be set with the following syntax: as = <|"a" -> 10|> <|"a" -> 10|> as["b"] = 20; as ...
4
votes
3answers
125 views

Dataset query for keys of upper levels

Say I have a Dataset like this: dat=Dataset[<|"a" -> 2, "b" -> "y", "c" -> {2, 3}|>] I want to get the keys of upper levels as elements in the ...
5
votes
3answers
116 views

Changing deep parts of expression specified by complex query

asso = <|"x" -> { <|"a" -> 5, "b" -> "y", "c" -> {5, 6, 7}|>, <|"a" -> 6, "b" -> "z", "c" -> {}|>} |> I want to ...
7
votes
1answer
120 views

How to make Cases work with associations?

Consider the following association of associations: ...
0
votes
0answers
36 views

How to pass var to Select[(#colunm == value) &] construct [duplicate]

I'm using a construct (more complex in fact as the value_ should take a list) to select some entries from an association with criteria: ...
7
votes
2answers
193 views

Map Values in 'nested' association

JSON often returns sort of 'nested' associations like so: ...
6
votes
1answer
161 views

How to filter this nested list of Association

For example, I have the following data ...
24
votes
1answer
443 views

Bug with Block & Lookup: Scope Variable Leak

After debugging a large chunk of code, I could identify this MWE. ...
4
votes
3answers
99 views

Pretty print of Association with Format, how to?

I have some assocations, containing a lot of data, lets say something like <|"x"->{... big list ...},....|> I would like to print these associations in ...
4
votes
0answers
58 views

how to count or extract Cases out of list of association that matches pattern

I have list of associations ...
4
votes
0answers
122 views

Extract a key from an Association?

I have some large nested expression containing associations and I'd like to extract the nth key inside one of them, using part syntax. Here's a tiny example: ...
2
votes
1answer
48 views

TakeLargestBy nested variable in Dataset

I would like to TakeLargestBy a nested variable in a Dataset. To be clearer, here is code to make an example dataset ...
4
votes
1answer
69 views

Merging unevaluated key/values

RuleDelayed is a supported key/value wrapper in Associations. What are general guidelines/idiomatic methods for working with ...