gluonts.dataset.schema package#
- class gluonts.dataset.schema.Translator(fields: typing.Dict[str, gluonts.dataset.schema.translate.Op] = <factory>, drop: bool = False)[source]#
Bases:
object
Simple translation for GluonTS Datasets.
A given translator transforms an input dictionary (data-entry) into an output dictionary.
Basic usage:
>>> tl = Translator.parse(x="a[0]") >>> data = {"a": [1, 2, 3]} >>> assert tl(data)["x"] == 1
A translator first copies all input fields into a new dictionary, before applying the translations. Thus, an empty Translator acts like the identity function for dictionaries:
>>> identity = Translator() >>> data = {"a": 1, "b": 2, "c": 3} >>> assert identity(data) == data
Using
Translator.parse(...)`
, one can define expressions to be applied to the input data. For example,Translator.parse(x="y")
will write the the value of y to the x column in the output.These right-hand expressions support indexing (e.g.
y[1]
), attribute access (e.g.x.T
) and method invocation (e.g.y.transpose(1, 0)
).- drop: bool = False#
- fields: Dict[str, gluonts.dataset.schema.translate.Op]#
- static parse(fields: Optional[dict] = None, drop: bool = False, **kwargs_fields) gluonts.dataset.schema.translate.Translator [source]#