assign_data
Functions:
Name | Description |
---|---|
assign_data |
|
Functions#
assign_data #
Assigns the data to the specified variable in the dataset.
If the variable exists and it is a data variable, then the DataArray for the specified variable in the dataset will simply have its data replaced with the new numpy array. If the variable exists and it is a coordinate variable, then the data will replace the coordinate data. If the variable does not exist in the dataset then a KeyError will be raised.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset
|
Dataset
|
The dataset where the data should be assigned. |
required |
data
|
NDArray[Any]
|
The data to assign. |
required |
variable_name
|
str
|
The name of the variable in the dataset to assign data to. |
required |
Raises:
Type | Description |
---|---|
KeyError
|
Raises a KeyError if the specified variable is not in the dataset's coords or data_vars dictionary. |
Returns:
Type | Description |
---|---|
Dataset
|
xr.Dataset: The dataset with data assigned to it. |