Group Abstract Group Abstract

Message Boards Message Boards

0
|
3.1K Views
|
10 Replies
|
6 Total Likes
View groups...
Share
Share this post:

How to understand the three parameters in Dataset

Posted 1 year ago

Hello,

A dataset is

dataset = Dataset[{
   <|"a" -> 1, "b" -> "x", "c" -> {1}|>,
   <|"a" -> 2, "b" -> "y", "c" -> {2, 3}|>,
   <|"a" -> 3, "b" -> "z", "c" -> {3}|>,
   <|"a" -> 4, "b" -> "x", "c" -> {4, 5}|>,
   <|"a" -> 5, "b" -> "y", "c" -> {5, 6, 7}|>,
   <|"a" -> 6, "b" -> "z", "c" -> {}|>}]

Apply a function f to every element in every row:

dataset[All, All, f]

Partition the dataset based on a column, applying further operators to each group:

dataset[GroupBy["b"], Catenate, "c"]

If Dataset can accept three parameters, the first one is the operation on the row, how do we understand the second and third ones?

And, why does this not work

dataset[GroupBy["b"], "c"]
POSTED BY: Zhenyu Zeng
10 Replies

In this case, the 1 is treated as an index or part so the first element of each c is extracted. Try

dataset[All, "c", 2]

I highly recommend reading Seth Chandler's book Query: Getting Information from Data with the Wolfram Language. A free notebook edition is available for download.

POSTED BY: Rohit Namjoshi
Posted 1 year ago
POSTED BY: Eric Rimbey
Posted 1 year ago
POSTED BY: Eric Rimbey
Posted 1 year ago
POSTED BY: Eric Rimbey
Posted 1 year ago

Thanks a lot. In the cases of data[f], what kind of f function can operate on dataset? May you give me an example? Can you give another example with four parameters or five parameters?

POSTED BY: Zhenyu Zeng
Posted 1 year ago
POSTED BY: Zhenyu Zeng
Posted 1 year ago
POSTED BY: Zhenyu Zeng
Posted 1 year ago

I have tried this

dataset[z, y, x, w]

Very difficult to understand this.

POSTED BY: Zhenyu Zeng
Posted 1 year ago

Too difficult for me to understand. May you teach me what is the meaning of this first

dataset[All, "c", 1]
POSTED BY: Zhenyu Zeng
Posted 1 year ago
POSTED BY: Eric Rimbey
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard