skbio.table.Table.__getitem__#

Table.__getitem__(args)[source]#

Handles row or column slices

Slicing over an individual axis is supported, but slicing over both axes at the same time is not supported. Partial slices, such as foo[0, 5:10] are not supported, however full slices are supported, such as foo[0, :].

Parameters:
argstuple or slice

The specific element (by index position) to return or an entire row or column of the data.

Returns:
float or spmatrix

A float is return if a specific element is specified, otherwise a spmatrix object representing a vector of sparse data is returned.

Raises:
IndexError
  • If the matrix is empty

  • If the arguments do not appear to be a tuple

  • If a slice on row and column is specified

  • If a partial slice is specified

Notes

Switching between slicing rows and columns is inefficient. Slicing of rows requires a CSR representation, while slicing of columns requires a CSC representation, and transforms are performed on the data if the data are not in the required representation. These transforms can be expensive if done frequently.