scipp.DataGroup#

class scipp.DataGroup(*args, **kwargs)#

A dict-like group of data. Additionally provides dims and shape properties.

DataGroup acts like a Python dict but additionally supports Scipp functionality such as positional- and label-based indexing and Scipp operations by mapping them to the values in the dict. This may happen recursively to support tree-like data structures.

New in version 23.01.0.

__init__(*args, **kwargs)#

Methods

__init__(*args, **kwargs)

all(*args, **kwargs)

any(*args, **kwargs)

apply(func, *args, **kwargs)

Call func on all values and return new DataGroup containing the results.

astype(*args, **kwargs)

bin(*args, **kwargs)

broadcast(*args, **kwargs)

ceil(*args, **kwargs)

clear()

copy([deep])

rtype:

DataGroup

flatten([dims])

floor(*args, **kwargs)

fold(dim, **kwargs)

get(k[,d])

group(*args, **kwargs)

groupby(*args, **kwargs)

hist(*args, **kwargs)

items()

keys()

max(*args, **kwargs)

mean(*args, **kwargs)

median(*args, **kwargs)

min(*args, **kwargs)

nanhist(*args, **kwargs)

nanmax(*args, **kwargs)

nanmean(*args, **kwargs)

nanmedian(*args, **kwargs)

nanmin(*args, **kwargs)

nanstd(*args, **kwargs)

nansum(*args, **kwargs)

nanvar(*args, **kwargs)

plot(*args, **kwargs)

pop(k[,d])

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem()

as a 2-tuple; but raise KeyError if D is empty.

rebin(*args, **kwargs)

rename(*args, **kwargs)

rename_dims(*args, **kwargs)

round(*args, **kwargs)

save_hdf5(filename)

Write an object out to file in HDF5 format.

setdefault(k[,d])

squeeze(*args, **kwargs)

std(*args, **kwargs)

sum(*args, **kwargs)

to(*args, **kwargs)

transform_coords(*args, **kwargs)

transpose([dims])

underlying_size()

rtype:

int

update([E, ]**F)

If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

values()

var(*args, **kwargs)

Attributes

bins

dims

Union of dims of all items.

ndim

Number of dimensions, i.e., len(self.dims).

shape

Union of shape of all items.

sizes

Dict combining dims and shape, i.e., mapping dim labels to their size.

__getitem__(name: str) Any#
__getitem__(name: ellipsis | int | tuple | slice | list | ndarray | Tuple[str, int | slice | list | ndarray | Variable] | Variable) DataGroup

Return item of given name or index all items.

When name is a string, return the item of the given name. Otherwise, this returns a new DataGroup, with items created by indexing the items in this DataGroup. This may perform, e.g., Scipp’s positional indexing, label-based indexing, or advanced indexing on items that are scipp.Variable or scipp.DataArray.

Label-based indexing is only possible when all items have a coordinate for the indexed dimension.

Advanced indexing comprises integer-array indexing and boolean-variable indexing. Unlike positional indexing, integer-array indexing works even when the item shapes are inconsistent for the indexed dimensions, provided that all items contain the maximal index in the integer array. Boolean-variable indexing is only possible when the shape of all items is compatible with the boolean variable.

apply(func, *args, **kwargs)#

Call func on all values and return new DataGroup containing the results.

Return type:

DataGroup

property dims: Tuple[str | None, ...]#

Union of dims of all items. Non-Scipp items are handled as dims=().

Return type:

Tuple[Optional[str], ...]

property ndim#

Number of dimensions, i.e., len(self.dims).

save_hdf5(filename)#

Write an object out to file in HDF5 format.

Return type:

None

property shape: Tuple[int | None, ...]#

Union of shape of all items. Non-Scipp items are handled as shape=().

Return type:

Tuple[Optional[int], ...]

property sizes: Dict[str, int | None]#

Dict combining dims and shape, i.e., mapping dim labels to their size.

Return type:

Dict[str, Optional[int]]