holoviews.util.transform module#
- class holoviews.util.transform.df_dim(obj, *args, **kwargs)[source]#
Bases:
dim
A subclass of dim which provides access to the DataFrame namespace along with tab-completion and type coercion allowing the expression to be applied on any columnar dataset.
- class holoviews.util.transform.dim(obj, *args, **kwargs)[source]#
Bases:
object
dim transform objects are a way to express deferred transforms on Datasets. dim transforms support all mathematical and bitwise operators, NumPy ufuncs and methods, and provide a number of useful methods for normalizing, binning and categorizing data.
- applies(dataset, strict=False)[source]#
Determines whether the dim transform can be applied to the Dataset, i.e. whether all referenced dimensions can be resolved.
- apply(dataset, flat=False, expanded=None, ranges=None, all_values=False, keep_index=False, compute=True, strict=False)[source]#
Evaluates the transform on the supplied dataset.
Parameters#
- dataset
Dataset object to evaluate the expression on
- flat
Whether to flatten the returned array
- expanded
Whether to use the expanded expand values
- ranges
Dictionary for ranges for normalization
- all_values
Whether to evaluate on all values Whether to evaluate on all available values, for some element types, such as Graphs, this may include values not included in the referenced column
- keep_index
For data types that support indexes, whether the index should be preserved in the result.
- compute
For data types that support lazy evaluation, whether the result should be computed before it is returned.
- strict
Whether to strictly check for dimension matches (if False, counts any dimensions with matching names as the same)
Returns#
- values
NumPy array computed by evaluating the expression
- bin(bins, labels=None)[source]#
Bins continuous values.
Bins continuous using the provided bins and assigns labels either computed from each bins center point or from the supplied labels.
Parameters#
bins : List or array containing the bin boundaries labels : List of labels to assign to each bin
If the bins are length N the labels should be length N-1
- categorize(categories, default=None)[source]#
Replaces discrete values with supplied categories
Replaces discrete values in input array into a fixed set of categories defined either as a list or dictionary.
Parameters#
categories : List or dict of categories to map inputs to default : Default value to assign if value not in categories
- clone(dimension=None, ops=None, dim_type=None)[source]#
Creates a clone of the dim expression optionally overriding the dim and ops.
- lognorm(limits=None)[source]#
- Unity-based normalization log scale.
Apply the same transformation as matplotlib.colors.LogNorm
Parameters#
limits : tuple of (min, max) defining the normalization range
- norm(limits=None)[source]#
Unity-based normalization to scale data into 0-1 range.
(values - min) / (max - min)
Parameters#
limits : tuple of (min, max) defining the normalization range
- classmethod pipe(func, *args, **kwargs)[source]#
Wrapper to give multidimensional transforms a more intuitive syntax. For a custom function ‘func’ with signature (*args, **kwargs), call as dim.pipe(func, *args, **kwargs).
- classmethod register(key, function)[source]#
Register a custom dim transform function which can from then on be referenced by the key.
- property str#
Casts values to strings or provides str accessor.
- holoviews.util.transform.easting_northing_to_lon_lat(easting, northing)[source]#
Projects the given easting, northing values into longitude, latitude coordinates.
easting and northing values are assumed to be in Web Mercator (aka Pseudo-Mercator or EPSG:3857) coordinates.
Parameters#
easting northing
Returns#
(longitude, latitude)
- class holoviews.util.transform.iloc(dim_expr)[source]#
Bases:
object
Implements integer array indexing for dim expressions.
- class holoviews.util.transform.loc(dim_expr)[source]#
Bases:
object
Implements loc for dim expressions.
- holoviews.util.transform.lognorm(values, min=None, max=None)[source]#
- Unity-based normalization on log scale.
Apply the same transformation as matplotlib.colors.LogNorm
Parameters#
values : Array of values to be normalized min : float, optional
Lower bound of normalization range
- maxfloat, optional
Upper bound of normalization range
Returns#
Array of normalized values
- holoviews.util.transform.lon_lat_to_easting_northing(longitude, latitude)[source]#
Projects the given longitude, latitude values into Web Mercator (aka Pseudo-Mercator or EPSG:3857) coordinates.
Longitude and latitude can be provided as scalars, Pandas columns, or Numpy arrays, and will be returned in the same form. Lists or tuples will be converted to Numpy arrays.
Parameters#
longitude latitude
Returns#
(easting, northing)
Examples#
>>> easting, northing = lon_lat_to_easting_northing(-74,40.71)
>>> easting, northing = lon_lat_to_easting_northing( np.array([-74]),np.array([40.71]) )
>>> df=pandas.DataFrame(dict(longitude=np.array([-74]),latitude=np.array([40.71])))
>>> df.loc[:, 'longitude'], df.loc[:, 'latitude'] = lon_lat_to_easting_northing( df.longitude,df.latitude )
- holoviews.util.transform.norm(values, min=None, max=None)[source]#
Unity-based normalization to scale data into 0-1 range.
(values - min) / (max - min)
Parameters#
values : Array of values to be normalized min : float, optional
Lower bound of normalization range
- maxfloat, optional
Upper bound of normalization range
Returns#
Array of normalized values