Tagged Questions

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

learn more… | top users | synonyms

11
votes
2answers
135 views

Listable functions thread over Associations; is this documented?

Thanks to a somewhat misapplied use of MapThread I learned of this behavior: ...
5
votes
3answers
105 views

How does MapThread work with Associations

According to the documentation, MapThread works on Association objects. But it doesn't seem to evaluate the passed function. For ...
2
votes
0answers
44 views

Automating constructor definitions (OptionValue eval time)? [duplicate]

I'm settling in on a programming pattern for "constructors." I can illustrate the pattern with the following example, which defines a constructor newBar for ...
8
votes
0answers
78 views

A bug in the overloading of MemberQ and FreeQ for Association?

While answering Pattern match for nested Association I came across behavior of MemberQ and FreeQ in 10.0.1 that I believe is ...
4
votes
3answers
91 views

Pattern match for nested Association

Suppose I have Association testAssoc=Association[a->Association[1->1,2->2],b->Association[1->1,2->2]] which ...
0
votes
1answer
41 views

Association of pure functions [duplicate]

I've encountered confusing behavior of Association when I try to use it for storing pure functions. For example: as = <|"1" -> # + 1 &|> ...
6
votes
3answers
177 views

GroupBy a list of associations with their keys

How can I go from ...
4
votes
3answers
76 views

Save associations to a file and reload

I have many (say 2 for now) associations that I want to save to a file ...
4
votes
1answer
76 views

Casting Dataset internal type from Assoc to Struct

Using: planets = ExampleData[{"Dataset", "Planets"}]; The full form of this projection displays the internal type def: ...
1
vote
0answers
63 views

Bug? Side effects when exporting to .mx

I seem to have encountered a bug when exporting to .mx, at least on OS X. Can anyone reproduce this? I am on MMA 10, OS X 10.9.4. ...
6
votes
1answer
66 views

Held keys in associations

Jacob Akkerboom commented: Note that PositionIndex does work correctly with held expressions, whereas this is a bit painful to implement using ...
8
votes
0answers
543 views

Dataset in Mathematica 10.0.1

Wolfram pages "Mathematica Quick Revision History" in Mathematica 10.0.1 release says: "New operators and compositions of operators enabled for associations functions such as Dataset and Query" ...
9
votes
5answers
182 views

Applying a function to a Dataset column conditional on another slot's value

How to apply a function to a column conditional on another slot's value? The Dataset documentation show only how to apply a function to named slots independently. The ...
5
votes
1answer
116 views

Mapping over an association producing an unexpected result

The documentation for associations says that the keys of an association are transparent for many operations. Map is one such operation. However, I am confronted ...
1
vote
0answers
41 views

How to pattern match an association? [duplicate]

I have the following: Clear[a, b]; a = {{1, 2, 3}, {4, 2, 5}, {6, 7, 8}}; b = GroupBy[a, #[[2]] &]; b whose output is: ...
6
votes
2answers
115 views

DeleteMissing level spec confusion

Given: titanic = ExampleData[{"Dataset", "Titanic"}] Why does this correctly delete Missing[] elements: ...
8
votes
2answers
112 views

Missing: KeyGroupBy?

Especially in tree-structured data, keys and values, being two sides of the same coin, frequently interchange roles. The ability to aggregate by value but not by key upsets the balance. How to ...
3
votes
1answer
76 views

How to efficiently select elements from a Hash?

How can I write an efficient version of the following selection statement: Keys[Select[hash, # < constant &]]; // AbsoluteTiming hash can be made from: ...
6
votes
1answer
75 views

Only String Keys supported in Dataset's Association Query?

Given data: titanic = ExampleData[{"Dataset", "Titanic"}] This Association Query works: ...
9
votes
2answers
164 views

Extracting values with multiple keys

I want to extract sorted data from a huge database based upon two (or more) keys in a very timely manner. Here is a reproducible toy example for two keys only: ...
9
votes
2answers
116 views

Problem constructing Association tables with some operators

First, set up the example Dataset from the documentation: titanic = ExampleData[{"Dataset", "Titanic"}]; Why does this fail: ...
5
votes
2answers
103 views

Replace Missing[Unmatched] with zero

After a left JoinAcross, I have a number of Missing["Unmatched"] values in my list of associations. I'd like to set them all ...
5
votes
3answers
219 views

difficulty abstracting the OptionValue pattern

I am building lots of functions that use Options and OptionValue and wanted to reduce the redundancy in the expressions that ...
2
votes
0answers
55 views

Functional-Style Fixed-Length Queue Object?

Following up on question Side-effecting an array in an association? and @Mr.Wizard's answer in there, I'm modernizing and tweaking Daniel Lichtblau's efficient queues and ran into a little roadblock. ...
3
votes
2answers
85 views

Side-effecting an array in an association?

I'm working on some classical data structures (stack, queue, etc.) and want to mimic oo style in MMA. As a first attempt, I want to store an array in an Association, like this: ...
2
votes
0answers
60 views

Adding an unused column creates an error in JoinAcross

I'd been having trouble using JoinAcross on two datasets. After going through the answers to my original question and fixing my code, I find I'm now having a ...
6
votes
0answers
145 views

Dataset: cannot reproduce a basic example. A bug?

Just to report: I try to reproduce the very first example for the Dataset from the Documentation Center: ...
8
votes
0answers
141 views

Benefit of using Dataset to collect SQLSelect output

Considering a DatabaseExample included with Mathematica: ...
7
votes
2answers
124 views

How to insert zero counts uniformly with Dataset Counts query

Missing[] is generated when an association does not contain the specified key. ...
1
vote
1answer
62 views

How can I append associations with uneven elements? [duplicate]

My dataset is pretty simple so far: ...
6
votes
1answer
117 views

Key->Value or Value when returning (multiple) parts of an Association

There seems to be an idiom whereby multiple parts generates Key->Value forms whereas for single part specifications, only a Value is returned. This however, can lead to inconsistencies as follows: ...
7
votes
0answers
208 views

Learning Resources for Data Science in the Wolfram Language

I'm delivering an upcoming course on Data Science with the programming/analysis done predominantly in the Wolfram Language. I created the following table to leverage students' familiarity with Lists ...
5
votes
1answer
147 views

Is there a faster way to Map an Association?

Consider mapping an existing Association in a manner such as this: ...
7
votes
3answers
237 views

AssociationMap to query Dataset across levels?

Is there a way to operate on Dataset across levels to apply a function f to a key -> value pair in an Association as follows: ...
5
votes
1answer
219 views

Converting hierarchies of rules to associations

The impossibility of MatchQ-ing inside and Association MatchQ-ing Associations (MMA 10) explains a problem I have. I would like ...
14
votes
1answer
249 views

MatchQ-ing Associations (MMA 10)

Consider {x->1} which has FullForm List[Rule[x, 1]] and, therefore, ...
23
votes
3answers
379 views

Changing Values in an Association using Map

I am trying to change the value of one key in an association based on the value of another key in that association. So if my association starts as: ...
2
votes
0answers
272 views

Dataset Mathematica 10.0

I started to use the new funcationality 'Dataset'in Mathematica 10.0. ...
3
votes
0answers
122 views

Combining key pivoting and lookup operators in Dataset

This question is related to this one re pivoting on keys. Because of the nesting, using Leonid's method as starting point - single key: ...
7
votes
3answers
320 views

Normal // Association // Dataset workaround for some user query operators

Given example tabular data (ie, with rows and columns, or "data frames") ...
11
votes
3answers
211 views

Equivalent of ReplaceAll for Associations?

Is there a nice (built-in) way to apply Replace-style rules to key-value pairs in an association? Something like ...
55
votes
3answers
2k views

How to make use of Associations?

I have been curious about it for long. Now that Mathematica 10 arrives, I think it's time to ask the question: How the new Association data structure would be used ...