Difference between i;;j and {i,...,j} output as dataset descending operators
Difference between i;;j and {i,...,j} output as dataset descending operators
I'm trying to understand the difference between {part1, part2, ...} and part1 ;; part2 descending operators semantics for datasets, and I uncovered that they behave differently from what I expect.
Let's create some sample dataset:
In[]:=
data=Dataset[Association[Thread[{"a","b","c"}#]]&/@Partition[Range[12],3]]
Out[]=
What looks like a bug is that the following two expressions provide a differently formatted output,
In[]:=
data[All,2;;3]
Out[]=
In[]:=
data[[All,2;;3]]
Out[]=
In[]:=
data[All,{2,3}]
Out[]=
In[]:=
data[[All,{2,3}]]
Out[]=
even though their normal forms are exactly the same, and "intuitively", they should mean the same thing?
In[]:=
Normal[data[All,{2,3}]]==Normal[data[All,2;;3]]
Out[]=
True
The documentation for Dataset has the following explanations in the Details section, which doesn't clarify things much:
◼
dataset[[All,m;;n]] extract columns m through n
◼
dataset[[All,{n1,n2,…}]] extract a subset of the columns
and in Descending operators subsection
◼
i;;j take parts i through j and apply subsequent operators to each part
◼
{part1,part2,…} take given parts and apply subsequent operators to each part
Note that if we apply these two different forms of Part to the underlying association, they yield the same results.
In[]:=
data1=Association[Thread[{"a","b","c"}#]]&/@Partition[Range[12],3]
Out[]=
{a1,b2,c3,a4,b5,c6,a7,b8,c9,a10,b11,c12}
In[]:=
data1[[All,{2,3}]]
Out[]=
{b2,c3,b5,c6,b8,c9,b11,c12}
In[]:=
data1[[All,2;;3]]
Out[]=
{b2,c3,b5,c6,b8,c9,b11,c12}
Could someone knowledgeable please confirm whether this indicates a gap in my understanding, or a bug in Dataset output form?