Questions tagged [associations]

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

Filter by
Sorted by
Tagged with
5 votes
2 answers
157 views

A Nothing for Associations

In the same way that Nothing disappears from Lists, is there a built-in that when it appears as the value in an association the ...
user avatar
  • 5,314
0 votes
1 answer
43 views

How to organise definitions that contain named parameters

I have lots of definitions of (usually numeric) quantities that depend on parameters; they're mostly matrices (in the actual code, there are many more definitions): ...
user avatar
  • 205
1 vote
1 answer
55 views

Using an Association as a Manipulate variable?

I would like to use an association in a Manipulate or a DynamicModule. Specifically, I'd like to click to change the Values of a list of Keys of an Association. Here is some non-working code that (...
user avatar
  • 2,058
0 votes
0 answers
23 views

Carryover comments when merging Associations

I am tasked with merging several nested associations containing vast amounts of commented text. The merging itself is rather easy but all comments go missing and would have to be inserted manually ...
user avatar
1 vote
1 answer
49 views

Performance tuning joinAcross (my version)

I have written what I think is a more or less complete version of JoinAcross with code below. I've done this to try to avoid the misbehavior I've observed in the ...
user avatar
  • 572
0 votes
1 answer
71 views

Datasets in Mathematica [closed]

I have two columns of data as two separately defined lists. I want to create a dataset and assign a key to each column. I tried this: ...
user avatar
  • 5
5 votes
1 answer
51 views

Replacement of Association value does not evaluate

Cos[a - b] /. {a -> 0, b -> 0} gives 1 However, <|1 -> Cos[a - b]|> /. {a -> 0, b -> 0} gives ...
user avatar
  • 15.6k
4 votes
3 answers
128 views

Change a group of values in a list of association

Noob here. I want to change the value of all the keys "e", that meet my filter criteria ("c" and "d" are above or equal 20). ...
user avatar
4 votes
1 answer
95 views

How to use ReplaceAll to create Association from List

I want to create a List of Associations from data in a two-dimensional List by using ...
user avatar
  • 199
3 votes
1 answer
120 views

Generic XML to Dataset

I am having trouble to transform XML data into a Mathematica Dataset of Associations. I want a dataset that follows the structure of the XML file with all its sublevels. Here is the example xml: ...
user avatar
1 vote
3 answers
99 views

Self modifying association (in a search of "THIS" keyword)

Imagine we have the following structure (like a module) ...
user avatar
0 votes
1 answer
80 views

How to create a dataset out of the entities?

I am working on learning how to create a dataset from a series of entities. I have the following function that finds all properties of a certain entity: ...
user avatar
0 votes
0 answers
32 views

How to keep track of multiple properties of entities?

I have the following lines of code: ...
user avatar
-3 votes
1 answer
98 views

How to find the distances to all buildings quickly?

I would like to create an association by mapping the function GeoDistance[Here,#]& over all buildings without missing locations in a reasonable amount of time less than 30 minutes. I have the ...
user avatar
5 votes
1 answer
123 views

How to select data using conditions from associations?

Consider the following dataset: ...
user avatar
  • 3,542
0 votes
1 answer
58 views

How to find all functions that accept level specifications as an argument?

How can I find a list of every function that takes a level specification as an argument?
user avatar
1 vote
2 answers
80 views

How to swap keys and values of an association? [duplicate]

How do you swap the values and keys of an Association in a manner similar to taking the transpose of a two-dimensional matrix or nested list? I am trying to solve the Wolfram Challenge Capital Cities ...
user avatar
3 votes
1 answer
46 views

Unexpected behavior with Derivative and a function parameters defined via an Association

I am confused by the following behavior: ...
user avatar
  • 339
18 votes
3 answers
487 views

Difference between HashTable datastructure and Association datastructure

Is there a difference in the runtimes between CreateDataStructure["HashTable"] and <||> in terms of inserting, ...
user avatar
  • 558
0 votes
2 answers
59 views

Add element to several associations automatically

I'm trying to add a certain element (testKey) to several already existing associations testAssoc1 and ...
user avatar
  • 3
1 vote
0 answers
67 views

How to work with structured data using graphs

Given that the functions for not only creating but also modifying Graph are functional programming creating copies it seems to me that it is a good idea to keep the vertices small, such as sticking to ...
user avatar
1 vote
1 answer
79 views

How do I consider a list of items as a single atom when threading?

Suppose I have the following list of items: ...
user avatar
  • 8,085
3 votes
0 answers
74 views

Association vs Pattern Matching: which one is better for data storage?

Say I have a few key-value pairs. I can store them with Association as ...
user avatar
  • 655
4 votes
1 answer
89 views

How to act with replacement on an association with syntax most similar to ReplaceAll

Replacements acting on Associations confuse me. I have read Pattern matching to a function evaluation inside an Association and How to use ReplaceAll and RuleDelayed with an Association? and I ...
user avatar
  • 3,553
1 vote
1 answer
61 views

Supplying options with an association [closed]

Let's say I have an association, like {"PlotStyle" -> Red}, and I want to use it to supply options to a function, such as ...
user avatar
  • 113
3 votes
1 answer
55 views

Converting Association to Matrix

Imagine I have the following association, where the keys are given as pairs of natural numbers ...
user avatar
  • 4,138
4 votes
1 answer
73 views

How can default valued be added in a Query?

I'm not understanding the the default values are not used to produced a length of 0 in the following example. What is the right way to add default values during a query? ...
user avatar
  • 12.3k
2 votes
1 answer
32 views

Changing Lists in Associations [closed]

On Mathematica 12.2 the code x = <||>; AssociateTo[x, "foo" -> {{1, 2}, {3, 4}}] x["foo"][[1]] += {0, 1} raises the error Set::setps: ...
user avatar
  • 333
3 votes
0 answers
67 views

Representing and Extracting Properties of a System Product Breakdown Structure (a Directed Acyclic Graph)

I am trying to analyze products using a product breakdown structure (PBS), which is a directed acyclic graph (DAG) that reflects a decomposition of the product into subproducts, sub-sub-products, and ...
user avatar
0 votes
0 answers
67 views

AssociationMap with formatting

Build an Association using AssociationMap, where the keys are the letters of the Alphabet[] and the values are the same letters with the following Style: The size of the letter should be set to twice ...
user avatar
3 votes
1 answer
80 views

How can two objects be equal, but only one of them be a Key in my association

What is going on here? There is an element in Keys[Dat] which is equal to {2.1,2.1}, but ...
user avatar
0 votes
2 answers
57 views

Selecting Keys when Lists are used as Keys

Analyzing a sequence after restructuring it, Counts returns a sequence similar to below: ...
user avatar
  • 1,024
2 votes
1 answer
61 views

Mathematica association does not work on symbols

Question about using an association within Replace. If I have an association which contains symbols like so: ...
user avatar
  • 74
0 votes
1 answer
84 views

Lists of labelled vectors, how to output a list of tuples which sum to zero

list = {{1, 1, 0}, {1, 0, 1}, {0, 1, 1}, {-1, 1, 0}, {1, -1, 0}, {-1, -1, 0}, {-1, 0, 1}, {1, 0,-1}, {-1, 0, -1}, {0, -1, 1}, {0, 1, -1}, {0, -1, -1}}; list2 = {{2, 0, 0}, {0, 2, 0}, {0, 0, 2}, {-2, ...
user avatar
  • 179
0 votes
1 answer
58 views

How to merge or group an association by another association or rule?

I eat the following food over 3 days and track the calories. (Days indexed by 1,2,3) ...
user avatar
1 vote
3 answers
67 views

Merging associations other than zeros

I am importing different associations and wanting to merge them. An example of these associations are: ...
user avatar
  • 73
5 votes
1 answer
54 views

Why is extracting values from an Association with 1 level slower than extracting values from a list of depth 1?

I am not looking for a solution or work-around, but an explanation. Here are six examples of doing a trivial operation on an association and a list. Initially, I was curious about the cost of calling ...
user avatar
  • 2,058
2 votes
0 answers
162 views

Lists of rules vs. Associations

It seems that generally, Mathematica users (or at least the Q&A I've read here) prefer associations to represent data in ways that many other languages would use structures. However, when ...
user avatar
  • 2,177
4 votes
2 answers
68 views

Reduction of nested association based on criteria

I have a nested association of the following form: ...
user avatar
  • 113
1 vote
1 answer
101 views

How to merge two DateObject list together?

I have two huge lists of flight data(one is around 7 million observations and another is around 1 million). The first one contains the city names, the departure time(accurate to the minute), and some ...
user avatar
4 votes
1 answer
156 views

Better way to create a Dataset?

I'd like to create a Dataset from an array, where each column's heading becomes the key for all elements in that column. I can accomplish this using nested Table commands, but was wondering if there ...
user avatar
  • 3,446
3 votes
1 answer
52 views

Front end fails to represent correctly boxes

Context Sometimes my front end misrepresents some output typically involving associations. For instance EmbedCode[CloudDeploy["hello, world"]] should ...
user avatar
  • 21.7k
7 votes
2 answers
176 views

Extract held value from Association

Consider an association which contains a key which must not be prematurely evaluated. assoc = <| key :> value |> For example, a value of ...
user avatar
6 votes
4 answers
212 views

Sorting Associations by DayName (day of week) using KeySort and/or KeySortBy

I have an association where the keys are the days of the week: ...
user avatar
  • 3,446
11 votes
1 answer
172 views

Mysterious Intersection on Association

This bug has been fixed in version 13.0 I have try to do an intersection on list of associations and the result is astonishing. Here an example: ...
user avatar
  • 331
3 votes
1 answer
46 views

How to extract items from a LearnedDistribution object?

I have never understood how to use Cases to extract items from objects (other than exactly copying code written by others which, again, means I don't understand). I ...
user avatar
  • 33.4k
1 vote
1 answer
44 views

Fastest way to convert two associations into a sparse matrix

I have two association $N$ and $C$ $N$ has this form : $N=<|x_1\rightarrow \{x_{1,1},...x_{1,p_1}\},x_2\rightarrow \{x_{2,1},...x_{2,p_2}\}...,x_D\rightarrow \{x_{D1},...x_{Dp_D}\} |>$ $C$ has ...
user avatar
  • 912
5 votes
1 answer
60 views

Grouping dataset by tags

Here is a slight modificaiton of Mathematica's example dataset from the documentation: ...
user avatar
2 votes
0 answers
54 views

Handling lists indexed with integer partitions

I am trying to do some exploration around the multi-dimensional version of [truncated moment problem], where I work with various distributions (uni- or multi-variate), and use some truncated moment ...
user avatar
  • 648
1 vote
1 answer
77 views

Redefining dot notation for Association

I'm trying to use Associations as object, and specifically want to use them as they are used in other languages using the dot notation. I'm using the code below to get started. ...
user avatar
  • 1,007

1
2 3 4 5
11