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.

Added in version 23.01.0.

__init__(*args, **kwargs)#

Methods

__init__(*args, **kwargs)

all([dim])

any([dim])

apply(func, *args, **kwargs)

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

astype(type, *[, copy])

bin([arg_dict])

broadcast(*[, dims, shape, sizes])

ceil()

clear()

copy([deep])

flatten([dims, to])

floor()

fold(dim, *[, dims, shape, sizes])

get(k[,d])

group(*args)

groupby(group, *[, bins])

hist([arg_dict])

items()

keys()

max([dim])

mean([dim])

median([dim])

min([dim])

nanhist([arg_dict])

nanmax([dim])

nanmean([dim])

nanmedian([dim])

nanmin([dim])

nanstd([dim])

nansum([dim])

nanvar([dim])

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([arg_dict])

rename([dims_dict])

rename_dims([dims_dict])

round()

save_hdf5(filename)

Write an object out to file in HDF5 format.

setdefault(k[,d])

squeeze([dim])

std([dim])

sum([dim])

to(*[, unit, dtype, copy])

transform_coords([targets, graph, ...])

transpose([dims])

underlying_size()

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([dim])

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)#

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.

Return type:

Any

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

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

Return type:

DataGroup[TypeVar(_R)]

property dims: tuple[str, ...]#

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

items()#
Return type:

ItemsView[str, TypeVar(_V)]

keys()#
Return type:

KeysView[str]

property ndim: int#

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=().

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

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

values()#
Return type:

ValuesView[TypeVar(_V)]