Skip to content

Slicing data using the slice control

Paul edited this page May 13, 2025 · 2 revisions

Overview

The slice control allows a user to to view specific ranges of their multi-dimensional data specified by a slicing expression. For example, you can view a 2-dimensional slice of an 3-dimensional array or tensor.

image

Supported data types

This control is only visible for the following currently supported types:

  • numpy.ndarray
  • torch.Tensor
  • tensorflow.python.framework.ops.EagerTensor
  • xarray.core.dataarray.DataArray

Slicing expression syntax

In Data Wrangler, we require at least one dimension to be a range to ensure that we have data that can be displayed in tabular format. For the full supported grammar see the docs.

Slice item

The basic unit of the slice expression is the slice item.

<start>:<stop>:<step>

Examples:

  • : = get all elements (same as not slicing)
  • 2: = get all elements with index >=2
  • :2 = get all elements with index <2
  • 1:7:2 = get every second item for indices from 1 to 6. This will select indices 1, 3, 5.
  • 5:1:-2 = get every second item from 5 to 1. This will select indices 5, 3.

Slice list

For multi-dimensional data, it is possible to specify one slice item per dimension. For example:

# Shape is (2, 2, 2)
[
  [[1, 2], [3, 4]],
  [[5, 6], [7, 8]]
]

Example slice expressions:

  • 0 = This will select [[1, 2], [3, 4]], same as 0,:,:
  • :,0 = This will select [[1, 2], [5, 6], same as :,0,:
  • 0,1,0:1 = This will select 3
Clone this wiki locally