koladata

Home
Overview
Fundamentals
Glossary
Cheatsheet
API Reference
Quick Recipes
Deep Dive
Common Pitfalls and Gotchas
Persistent Storage

View the Project on GitHub google/koladata

kd_ext.storage.data_slice_path.DataSlicePath API

A data slice path.

DataSlicePath.__init__(self, actions: tuple[DataSliceAction, ...]) -> None

Initialize self.  See help(type(self)) for accurate signature.

DataSlicePath.concat(self, other: DataSlicePath) -> DataSlicePath

Aliases:

Returns a new data slice path with the given data slice path appended.

DataSlicePath.depth

Returns the depth of this data slice path from the root.

That is the same as the number of actions in the path. The root is at the
empty path, which has depth 0. A path ".foo" has depth 1, ".foo[:]" has
depth 2, ".foo[:].bar" has depth 3, etc.

DataSlicePath.evaluate(self, data_slice: kd.types.DataSlice) -> kd.types.DataSlice

Aliases:

Evaluates this path on `data_slice`.

Args:
  data_slice: the DataSlice on which this path must be evaluated.

Returns:
  The part of `data_slice` at the path defined by `self`.

Raises:
  ValueError: if this path is not valid for `data_slice`.

DataSlicePath.extended_with_action(self, action: DataSliceAction) -> DataSlicePath

Aliases:

Returns a new data slice path with the given action appended.

DataSlicePath.from_actions(actions: list[DataSliceAction]) -> DataSlicePath

Aliases:

DataSlicePath.parse_from_string(data_slice_path: str) -> DataSlicePath

Aliases:

Parses the given string to return a data slice path.

The empty string is a valid data slice path. Given a valid data slice path,
we can obtain another valid data slice path by appending further actions:
* append '.get_keys()' to get the keys of a dict.
* append '.get_values()' to get the values of a dict.
* append '[:]' to explode a list.
* append '.attribute_name' to get an attribute of an entity. The attribute
  name must be a valid Python identifier to be used with this dot syntax.
  You can test for that by using some_string.isidentifier().
* append '.get_attr("base64_encoded_attribute_name")' to get an attribute of
  an entity. The base64-encoded attribute name can be enclosed in single or
  double quotes. This syntax is useful when the attribute name contains
  special characters such as dots or quotes.

Args:
  data_slice_path: the data slice path to parse. It must be valid according
    to the rules above.

Returns:
  The parsed data slice path.

Raises:
  ValueError: if the data_slice_path is not valid.

DataSlicePath.to_string(self) -> str

Aliases:

Returns the data slice path as a string.