Message Boards Message Boards

3
|
3411 Views
|
1 Reply
|
3 Total Likes
View groups...
Share
Share this post:

Dataset[] and Part[] Problem?

Posted 10 years ago

Given this...

dataset = Dataset[{
   <|"a" -> 1|>,
   <|"a" -> 2|>,
   <|"a" -> 3|>,
   <|"a" -> 4|>,
   <|"a" -> 5|>,
   <|"a" -> 6|>,
   <|"a" -> 7|>,
   <|"a" -> 8|>,
   <|"a" -> 9|>
   }]

And given that this works...

dataset[[1 ;; -1]]

Then shouldn't this work...

dataset[[1 ;; -1 ;; 2]]

For me, the last input returns...

Missing["PartInvalid", 1 ;; -1 ;; 2]

Just by the way, all three of the above statements work if dataset is defined as follows:

dataset = {
  <|"a" -> 1|>,
  <|"a" -> 2|>,
  <|"a" -> 3|>,
  <|"a" -> 4|>,
  <|"a" -> 5|>,
  <|"a" -> 6|>,
  <|"a" -> 7|>,
  <|"a" -> 8|>,
  <|"a" -> 9|>
  }
POSTED BY: Brad Varey

Although one would hope that the form

dataset[[1 ;; -1 ;; 2]]

would be supported, in the documentation for Dataset only the form with a single instance of ;; is stated. So the documentation explicitly excludes the form you'd like to have work. Generally, I have found, the documentation is the design document for a function and if something is not explicitly mentioned, it often (though not always) is not supported.

POSTED BY: David Reiss
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract