holoviews.core.data.grid module#
- class holoviews.core.data.grid.GridInterface(*, name)[source]#
Bases:
DictInterfaceInterface for simple dictionary-based dataset format using a compressed representation that uses the cartesian product between key dimensions. As with DictInterface, the dictionary keys correspond to the column (i.e. dimension) names and the values are NumPy arrays representing the values in that column.
To use this compressed format, the key dimensions must be orthogonal to one another with each key dimension specifying an axis of the multidimensional space occupied by the value dimension data. For instance, given an temperature recordings sampled regularly across the earth surface, a list of N unique latitudes and M unique longitudes can specify the position of NxM temperature samples.
Methods
add_dimension(dataset, dimension, dim_pos, ...)Returns a copy of the data with the dimension values added.
assign(dataset, new_data)Adds a dictionary containing data for multiple new dimensions to a copy of the dataset.data.
canonicalize(dataset, data[, data_coords, ...])Canonicalize takes an array of values as input and reorients and transposes it to match the canonical format expected by plotting functions.
compute(dataset)Converts a lazy Dataset to a non-lazy, in-memory format.
coords(dataset, dim[, ordered, expanded, edges])Returns the coordinates along a dimension.
dtype(dataset, dimension)Returns the dtype for the selected dimension.
iloc(dataset, index)Implements integer indexing on the rows and columns of the data.
isscalar(dataset, dim)Whether the selected dimension is a scalar value.
length(dataset)Returns the number of rows in the Dataset.
persist(dataset)Persists the data backing the Dataset in memory.
range(dataset, dimension)Computes the minimum and maximum value along a dimension.
reindex(dataset, kdims, vdims)Reindexes data given new key and value dimensions.
sample(dataset[, samples])Samples the gridded data into dataset of samples.
shape(dataset[, gridded])Returns the shape of the data.
validate(dataset[, vdims])Validation runs after the Dataset has been constructed and should validate that the Dataset is correctly formed and contains all declared dimensions.
values(dataset, dim[, expanded, flat, ...])Returns the values along a dimension of the dataset.
aggregate
concat
concat_dim
dimension_type
groupby
init
invert_index
irregular
key_select_mask
mask
ndloc
packed
select
sort
Parameter Definitions
- classmethod add_dimension(dataset, dimension, dim_pos, values, vdim)[source]#
Returns a copy of the data with the dimension values added.
- Parameters:
- dataset
Dataset The Dataset to add the dimension to
- dimension
Dimension The dimension to add
- dim_pos
int The position in the data to add it to
- valuesarray_like
The array of values to add
- vdimbool
Whether the data is a value dimension
- dataset
- Returns:
dataA copy of the data with the new dimension
- classmethod assign(dataset, new_data)[source]#
Adds a dictionary containing data for multiple new dimensions to a copy of the dataset.data.
- Parameters:
- dataset
Dataset The Dataset to add the dimension to
- new_data
dict Dictionary containing new data to add to the Dataset
- dataset
- Returns:
dataA copy of the data with the new data dimensions added
- classmethod canonicalize(dataset, data, data_coords=None, virtual_coords=None)[source]#
Canonicalize takes an array of values as input and reorients and transposes it to match the canonical format expected by plotting functions. In certain cases the dimensions defined via the kdims of an Element may not match the dimensions of the underlying data. A set of data_coords may be passed in to define the dimensionality of the data, which can then be used to np.squeeze the data to remove any constant dimensions. If the data is also irregular, i.e. contains multi-dimensional coordinates, a set of virtual_coords can be supplied, required by some interfaces (e.g. xarray) to index irregular datasets with a virtual integer index. This ensures these coordinates are not simply dropped.
- classmethod compute(dataset)[source]#
Converts a lazy Dataset to a non-lazy, in-memory format.
- Parameters:
- dataset
Dataset The dataset to compute
- dataset
- Returns:
DatasetDataset with non-lazy data
Notes
This is a no-op if the data is already non-lazy.
- classmethod coords(dataset, dim, ordered=False, expanded=False, edges=False)[source]#
Returns the coordinates along a dimension. Ordered ensures coordinates are in ascending order and expanded creates ND-array matching the dimensionality of the dataset.
- classmethod dtype(dataset, dimension)[source]#
Returns the dtype for the selected dimension.
- Parameters:
- dataset
Dataset The dataset to query
- dimension
strorDimension Dimension to return the dtype for
- dataset
- Returns:
numpy.dtypeThe dtype of the selected dimension
- classmethod iloc(dataset, index)[source]#
Implements integer indexing on the rows and columns of the data.
- Parameters:
- Returns:
dataIndexed data
Notes
Only implement for tabular interfaces.
- classmethod length(dataset)[source]#
Returns the number of rows in the Dataset.
- Parameters:
- dataset
Dataset The dataset to get the length from
- dataset
- Returns:
intLength of the data
- classmethod persist(dataset)[source]#
Persists the data backing the Dataset in memory.
- Parameters:
- dataset
Dataset The dataset to persist
- dataset
- Returns:
DatasetDataset with the data persisted to memory
Notes
This is a no-op if the data is already in memory.
- classmethod range(dataset, dimension)[source]#
Computes the minimum and maximum value along a dimension.
- Parameters:
- dataset
Dataset The dataset to query
- dimension
strorDimension Dimension to compute the range on
- dataset
- Returns:
tuple[Any,Any]Tuple of (min, max) values
Notes
In the past categorical and string columns were handled by sorting the values and taking the first and last value. This behavior is deprecated and will be removed in 2.0. In future the range for these columns will be returned as (None, None).
- classmethod reindex(dataset, kdims, vdims)[source]#
Reindexes data given new key and value dimensions.
- classmethod sample(dataset, samples=None)[source]#
Samples the gridded data into dataset of samples.
- classmethod validate(dataset, vdims=True)[source]#
Validation runs after the Dataset has been constructed and should validate that the Dataset is correctly formed and contains all declared dimensions.
- classmethod values(dataset, dim, expanded=True, flat=True, compute=True, keep_index=False, canonicalize=True)[source]#
Returns the values along a dimension of the dataset.
- Parameters:
- dataset
Dataset The dataset to query
- dimension
strorDimension Dimension to return the values for
- expandedbool,
defaultTrue When false returns unique values along the dimension
- flatbool,
defaultTrue Whether to flatten the array
- computebool,
defaultTrue Whether to load lazy data into memory as a NumPy array
- keep_indexbool,
defaultFalse Whether to return the data with an index (if present)
- dataset
- Returns:
- array_like
Dimension values in the requested format
Notes
The expanded keyword has different behavior for gridded interfaces where it determines whether 1D coordinates are expanded into a multi-dimensional array.