Skip to main content

Attributes

GitHub source

Attributes

evo.objects.typed.attributes.Attributes

A collection of Geoscience Object Attributes

__getitem__

__getitem__(index_or_name: int | str) -> Attribute | PendingAttribute

Get an attribute by index or name.

Parameters:

NameTypeDescriptionDefault
index_or_nameint | strEither an integer index or the name/key of the attribute.required

Returns:

TypeDescription
Attribute | PendingAttributeThe attribute at the specified index or with the specified name/key. If a string is provided and no matching attribute exists, returns a PendingAttribute that can be used as a target for compute tasks.

Raises:

TypeDescription
IndexErrorIf the integer index is out of range.

to_dataframe

to_dataframe(*keys: str, fb: IFeedback = NoFeedback) -> pd.DataFrame

Load a DataFrame containing the values from the specified attributes in the object.

Parameters:

NameTypeDescriptionDefault
keysstrOptional list of attribute keys to filter the attributes by. If no keys are provided, all attributes will be loaded.()
fbIFeedbackOptional feedback object to report download progress.NoFeedback

Returns:

TypeDescription
DataFrameA DataFrame containing the values from the specified attributes. Column name(s) will be updated based on the attribute names.

append_attribute

append_attribute(df: DataFrame, fb: IFeedback = NoFeedback)

Add a new attribute to the object.

Parameters:

NameTypeDescriptionDefault
dfDataFrameDataFrame containing the values for the new attribute. The DataFrame should contain a single column.required
fbIFeedbackOptional feedback object to report upload progress.NoFeedback

Raises:

TypeDescription
ValueErrorIf the DataFrame does not contain exactly one column.

append_attributes

append_attributes(df: DataFrame, fb: IFeedback = NoFeedback)

Add new attributes to the object.

Parameters:

NameTypeDescriptionDefault
dfDataFrameDataFrame containing the values for the new attributes.required
fbIFeedbackOptional feedback object to report upload progress.NoFeedback

set_attributes

set_attributes(df: DataFrame, fb: IFeedback = NoFeedback)

Set the attributes of the object to match the provided DataFrame.

Parameters:

NameTypeDescriptionDefault
dfDataFrameDataFrame containing the values for the new attributes.required
fbIFeedbackOptional feedback object to report upload progress.NoFeedback

validate_lengths

validate_lengths(expected_length: int) -> None

Validate that all attributes have the expected length.

Parameters:

NameTypeDescriptionDefault
expected_lengthintThe expected number of values for each attribute.required

Raises:

TypeDescription
ObjectValidationErrorIf any attribute has a different length.

What is the reason for your feedback?