Skip to main content
24 votes
Accepted

Query: adding additional operator changes meaning of preceding operators

This is a corner case that occurs when ascending operators are interleaved between descending operators. This case falls into an undocumented grey area. In the Details and Options section of the ...
WReach's user avatar
  • 68.9k
14 votes
Accepted

Transpose fail in 11.1 Dataset

As observed in the question, the problem lies with the type information of the dataset. Specifically, the type information for the innermost association is missing (i.e. "any type"). This causes the ...
WReach's user avatar
  • 68.9k
12 votes

Slicing an Association with named key span without normalizing?

I don't know if this is useful to you but it seems a little cleaner than your own code: ...
Mr.Wizard's user avatar
  • 272k
11 votes
Accepted

How to filter this nested list of Association

We must adjust the Select operator to account for the fact that the keys "a" and "b" are ...
WReach's user avatar
  • 68.9k
11 votes

How does Query decide the order in which the functions are applied?

@Lee's answer shows how to circumvent the problem by using RightComposition (/*) instead of ...
Lukas Lang's user avatar
  • 34.1k
10 votes

Simplifying a reverse Fold for a Query

A more direct solution with Fold using Range to reverse. With ...
Edmund's user avatar
  • 42.3k
10 votes

Does anyone know a way to use patterns in Query?

There is no built-in facility to do this kind of transformation, but we can define our own query operator like so: ...
WReach's user avatar
  • 68.9k
10 votes
Accepted

How can I understand this example of Query taken from current Mathematica documentation?

This is "ascending" sub-query operator syntax. It operates on the entire row to produce a new row with the specified keys and values as the operator applied to the row. However, the ...
Edmund's user avatar
  • 42.3k
9 votes
Accepted

Does anyone know a way to use patterns in Query?

Since I am not aware of any built-ins, here is another custom solution: ...
Lukas Lang's user avatar
  • 34.1k
8 votes

Large Dataset query fails if column contains Missing

Extended comment converted to a non-answer, nailing down what is required to trigger this bug: Here's a simple Dataset with one key having all string values, ...
Jason B.'s user avatar
  • 68.7k
8 votes

Unexpected behavior of PreIncrement when querying associations

The 2nd example given under Query > Properties & Relations tells us Before being applied, Query expressions are "compiled" into ordinary compositions of ...
m_goldberg's user avatar
  • 108k
8 votes
Accepted

Query inside Dynamic triggers continuous high CPU load for FE

A quick fix is to add TrackedSymbols :> {searchstring} to the Dynamic. But at the end it is just another example from a ...
Kuba's user avatar
  • 137k
7 votes
Accepted

Query from Association of Associations Dataset

How about: ...
Carl Woll's user avatar
  • 131k
7 votes

Applying a function by Key pattern, preserving Association order

This should do what you want: ...
JEM_Mosig's user avatar
  • 3,003
7 votes

Getting slices of a nested Association via Query

This will work: db // Query[ Drop[ #, None, {3} ]& @* Transpose, 2, 1 ;; 3 ] {<|"English" -> "a", "Greek" -> "α"|>, <|"English" -> "b", "Greek" -...
gwr's user avatar
  • 13.5k
7 votes
Accepted

Query and Dataset Syntax Peculiarities

Let's go through it blow-by-blow... Query[DeleteMissing] @ d1 This will apply DeleteMissing to the list of associations. The documentation says: DeleteMissing[...
WReach's user avatar
  • 68.9k
7 votes

Select dataset rows that meet a mathematical criterion in a column

Assuming that you intend to use a Dataset with named rows (and being aware that this means that each row must have a unique name), one way is: ...
Joshua Schrier's user avatar
7 votes
Accepted

How can default valued be added in a Query?

The issue is indeed that since both defaulter and Length are ascending operators, they are applied "bottom-up". That ...
WReach's user avatar
  • 68.9k
6 votes
Accepted

Passing values from a list to Select during a Dataset query

You can use Function to proceed myDs[Select[Or @@ (Function[id, #id == id] /@ {5, 4, 1}) &], "name"] but there are ...
Kuba's user avatar
  • 137k
6 votes

Getting slices of a nested Association via Query

@gwr led me to try Transpose after the first subquery as an ascending operator (/*). ...
Sascha's user avatar
  • 8,469
6 votes

Slicing an Association with named key span without normalizing?

From version 10.4 onward, we can define keySpan like this: ...
WReach's user avatar
  • 68.9k
6 votes

Query inside Dynamic triggers continuous high CPU load for FE

You may use the TrackedSymbols option on either DynamicModule or Dynamic. From the comments ...
Edmund's user avatar
  • 42.3k
6 votes

How to pull out the underlying query syntax being used by dataset?

We can extract the query from the dataset object through pattern-matching: ...
WReach's user avatar
  • 68.9k
6 votes

How does Query decide the order in which the functions are applied?

Using RightComposition in the expression which fails will produce the result you are looking for: ...
Lee's user avatar
  • 981
6 votes
Accepted

Select specific rows of a dataset

Query[Select[MemberQ[{2, 4, 5}, #a] &]]@dataset
Slepecky Mamut's user avatar
6 votes

Select specific rows of a dataset

You can also use dataset[Select[MatchQ[#a, 2 | 4 | 5] &]] Select[MatchQ[#a, 2 | 4 | 5] &] @ dataset ...
kglr's user avatar
  • 396k
6 votes

A simple way to extract information from this dataset with Query?

Here is a way that produces output that conforms to the first option: ...
WReach's user avatar
  • 68.9k
6 votes
Accepted

Generating Google BigQuery API Access Token in Wolfram Language

Google Cloud Platform uses the RS256 algorithm to send JWT and retrieve the tokens, all that is needed is to make a function that builds the JWT and creates a signature using ...
Cabral's user avatar
  • 138
5 votes

Applying a function by Key pattern, preserving Association order

Here is a way that uses MapIndexed: keyPatternQuery[patt_ -> f_] := MapIndexed[If[MatchQ[#2, {Key[patt]}], f[#], #]&] ...
WReach's user avatar
  • 68.9k
5 votes
Accepted

How to pull out the underlying query syntax being used by dataset?

There is a probably an internal function that can extract this information, but if not, you could use the following function to do so: ...
Carl Woll's user avatar
  • 131k

Only top scored, non community-wiki answers of a minimum length are eligible