holoviews.core.data.spatialpandas module#
- class holoviews.core.data.spatialpandas.SpatialPandasInterface(*, name)[source]#
Bases:
MultiInterfaceMethods
add_dimension(dataset, dimension, dim_pos, ...)Returns a copy of the data with the dimension values added.
applies(obj)Indicates whether the interface is designed specifically to handle the supplied object's type.
as_dframe(dataset)Returns the data of a Dataset as a dataframe avoiding copying if it already a dataframe type.
dframe(dataset, dimensions)Returns the data as a pandas.DataFrame containing the selected dimensions.
dtype(dataset, dimension)Returns the dtype for the selected dimension.
has_holes(dataset)Whether the Dataset contains geometries with holes.
holes(dataset)Returns a list of lists of arrays containing the holes for each geometry in the Dataset.
iloc(dataset, index)Implements integer indexing on the rows and columns of the data.
isscalar(dataset, dim[, per_geom])Tests if dimension is scalar in each subpath.
length(dataset)Returns the length of the multi-tabular dataset making it appear like a single array of concatenated subpaths separated by NaN values.
loaded()Indicates whether the required dependencies are loaded.
nonzero(dataset)Returns a boolean indicating whether the Dataset contains any data.
range(dataset, dim)Computes the minimum and maximum value along a dimension.
redim(dataset, dimensions)Renames dimensions in the data.
reindex(dataset[, kdims, vdims])Reindexes data given new key and value dimensions.
select(dataset[, selection_mask])Applies selectiong on all the subpaths.
select_mask(dataset, selection)Given a Dataset object and a dictionary with dimension keys and selection keys (i.e. tuple ranges, slices, sets, lists, or literals) return a boolean mask over the rows in the Dataset object that have been selected.
shape(dataset)Returns the shape of all subpaths, making it appear like a single array of concatenated subpaths separated by NaN values.
split(dataset, start, end, datatype, **kwargs)Splits a multi-interface Dataset into regular Datasets using regular tabular interfaces.
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, dimension[, expanded, flat, ...])Returns a single concatenated array of all subpaths separated by NaN values.
aggregate
array_type
base_interface
data_types
dimension_type
frame_type
geo_column
geom_dims
groupby
init
sample
series_type
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 applies(obj)[source]#
Indicates whether the interface is designed specifically to handle the supplied object’s type. By default simply checks if the object is one of the types declared on the class, however if the type is expensive to import at load time the method may be overridden.
- classmethod as_dframe(dataset)[source]#
Returns the data of a Dataset as a dataframe avoiding copying if it already a dataframe type.
- Parameters:
- dataset
Dataset The dataset to convert
- dataset
- Returns:
DataFrameDataFrame representation of the data
- base_interface[source]#
alias of
PandasInterface
- classmethod dframe(dataset, dimensions)[source]#
Returns the data as a pandas.DataFrame containing the selected dimensions.
- 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 has_holes(dataset)[source]#
Whether the Dataset contains geometries with holes.
- Parameters:
- dataset
Dataset The dataset to check
- dataset
- Returns:
- bool
Whether the Dataset contains geometries with holes
Notes
Only meaningful to implement on Interfaces that support geometry data.
- classmethod holes(dataset)[source]#
Returns a list of lists of arrays containing the holes for each geometry in the Dataset.
- Parameters:
- dataset
Dataset The dataset to extract holes from
- dataset
- Returns:
list[list[np.ndarray]]List of list of arrays representing geometry holes
Notes
Only meaningful to implement on Interfaces that support geometry data.
- 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 isscalar(dataset, dim, per_geom=False)[source]#
Tests if dimension is scalar in each subpath.
- classmethod length(dataset)[source]#
Returns the length of the multi-tabular dataset making it appear like a single array of concatenated subpaths separated by NaN values.
- classmethod nonzero(dataset)[source]#
Returns a boolean indicating whether the Dataset contains any data.
- Parameters:
- dataset
Dataset The dataset to check
- dataset
- Returns:
- bool
Whether the dataset is not empty
- classmethod range(dataset, dim)[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 redim(dataset, dimensions)[source]#
Renames dimensions in the data.
- Parameters:
- Returns:
dataData after the dimension names have been transformed
Notes
Only meaningful for data formats that store dimension names.
- classmethod reindex(dataset, kdims=None, vdims=None)[source]#
Reindexes data given new key and value dimensions.
- classmethod select(dataset, selection_mask=None, **selection)[source]#
Applies selectiong on all the subpaths.
- classmethod select_mask(dataset, selection)[source]#
Given a Dataset object and a dictionary with dimension keys and selection keys (i.e. tuple ranges, slices, sets, lists, or literals) return a boolean mask over the rows in the Dataset object that have been selected.
- classmethod shape(dataset)[source]#
Returns the shape of all subpaths, making it appear like a single array of concatenated subpaths separated by NaN values.
- classmethod split(dataset, start, end, datatype, **kwargs)[source]#
Splits a multi-interface Dataset into regular Datasets using regular tabular interfaces.
- holoviews.core.data.spatialpandas.from_multi(eltype, data, kdims, vdims)[source]#
Converts list formats into spatialpandas.GeoDataFrame.
- Parameters:
- eltype
Element type to convert
- data
The original data
- kdims
The declared key dimensions
- vdims
The declared value dimensions
- Returns:
AGeoDataFramecontaininginthelistbasedformat.
- holoviews.core.data.spatialpandas.from_shapely(data)[source]#
Converts shapely based data formats to spatialpandas.GeoDataFrame.
- Parameters:
- data
A list of shapely objects or dictionaries containing shapely objects
- Returns:
AGeoDataFramecontainingtheshapelygeometrydata.
- holoviews.core.data.spatialpandas.geom_array_to_array(geom_array, index, expand=False, geom_type=None)[source]#
Converts spatialpandas extension arrays to a flattened array.
- Parameters:
- geom
spatialpandasgeometry - index
The column index to return
- geom
- Returns:
Flattenedarray
- holoviews.core.data.spatialpandas.geom_to_array(geom, index=None, multi=False, geom_type=None)[source]#
Converts spatialpandas geometry to an array.
- Parameters:
- geom
spatialpandasgeometry - index
The column index to return
- multi
Whether to concatenate multiple arrays or not
- geom
- Returns:
Arrayorlistofarrays.
- holoviews.core.data.spatialpandas.geom_to_holes(geom)[source]#
Extracts holes from spatialpandas Polygon geometries.
- Parameters:
- geom
spatialpandasgeometry
- geom
- Returns:
Listofarraysrepresentingholes
- holoviews.core.data.spatialpandas.get_geom_type(gdf, col)[source]#
Return the HoloViews geometry type string for the geometry column.
- holoviews.core.data.spatialpandas.get_value_array(data, dimension, expanded, keep_index, geom_col, is_points, geom_length=<function geom_length>)[source]#
Returns an array of values from a GeoDataFrame.
- Parameters:
- data
GeoDataFrame - dimension
The dimension to get the values from
- expanded
Whether to expand the value array
- keep_index
Whether to return a Series
- geom_col
The column in the data that contains the geometries
- is_points
Whether the geometries are points
- geom_length
The function used to compute the length of each geometry
- data
- Returns:
Anarraycontainingthevaluesalongadimension
- holoviews.core.data.spatialpandas.to_geom_dict(eltype, data, kdims, vdims, interface=None)[source]#
Converts data from any list format to a dictionary based format.
- Parameters:
- eltype
Element type to convert
- data
The original data
- kdims
The declared key dimensions
- vdims
The declared value dimensions
- Returns:
Alistofdictionariescontaininggeometrycoordinatesandvalues.
- holoviews.core.data.spatialpandas.to_spatialpandas(data, xdim, ydim, columns=None, geom='point')[source]#
Converts list of dictionary format geometries to spatialpandas line geometries.
- Parameters:
- data
List of dictionaries representing individual geometries
- xdim
Name of x-coordinates column
- ydim
Name of y-coordinates column
- columns
List of columns to add
- geom
The type of geometry
- Returns:
Aspatialpandas.GeoDataFrameversionofthedata