xarray.IndexVariable¶
-
class
xarray.IndexVariable(dims, data, attrs=None, encoding=None, fastpath=False)¶ Wrapper for accommodating a pandas.Index in an xarray.Variable.
IndexVariable preserve loaded values in the form of a pandas.Index instead of a NumPy array. Hence, their values are immutable and must always be one- dimensional.
They also have a name property, which is the name of their sole dimension unless another name is given.
-
__init__(dims, data, attrs=None, encoding=None, fastpath=False)¶ Parameters: dims : str or sequence of str
Name(s) of the the data dimension(s). Must be either a string (only for 1D data) or a sequence of strings with length equal to the number of dimensions.
data : array_like
Data array which supports numpy-like data access.
attrs : dict_like or None, optional
Attributes to assign to the new variable. If None (default), an empty attribute dictionary is initialized.
encoding : dict_like or None, optional
Dictionary specifying how to encode this array’s data into a serialized format like netCDF4. Currently used keys (for netCDF) include ‘_FillValue’, ‘scale_factor’, ‘add_offset’ and ‘dtype’. Well-behaved code to serialize a Variable should ignore unrecognized encoding items.
Methods
__init__(dims, data[, attrs, encoding, fastpath])Parameters: all([dim, axis])Reduce this Variable’s data by applying all along some dimension(s). any([dim, axis])Reduce this Variable’s data by applying any along some dimension(s). argmax([dim, axis, skipna])Reduce this Variable’s data by applying argmax along some dimension(s). argmin([dim, axis, skipna])Reduce this Variable’s data by applying argmin along some dimension(s). argsort([axis, kind, order])Returns the indices that would sort this array. astype(dtype[, order, casting, subok, copy])Copy of the array, cast to a specified type. broadcast_equals(other[, equiv])True if two Variables have the values after being broadcast against each other; otherwise False. chunk([chunks, name, lock])Coerce this array’s data into a dask arrays with the given chunks. clip([min, max, out])Return an array whose values are limited to [min, max].coarsen(windows, func[, boundary, side])Apply compute(**kwargs)Manually trigger loading of this variable’s data from disk or a remote source into memory and return a new variable. concat(variables[, dim, positions, shortcut])Specialized version of Variable.concat for IndexVariable objects. conj()Complex-conjugate all elements. conjugate()Return the complex conjugate, element-wise. copy([deep, data])Returns a copy of this object. count([dim, axis])Reduce this Variable’s data by applying count along some dimension(s). cumprod([dim, axis, skipna])Apply cumprod along some dimension of Variable. cumsum([dim, axis, skipna])Apply cumsum along some dimension of Variable. equals(other[, equiv])True if two Variables have the same dimensions and values; otherwise False. expand_dims(*args)fillna(value)get_axis_num(dim)Return axis number(s) corresponding to dimension(s) in this array. get_level_variable(level)Return a new IndexVariable from a given MultiIndex level. identical(other)Like equals, but also checks attributes. isel([indexers, drop])Return a new array indexed along the specified dimension(s). isnull(*args, **kwargs)item(*args)Copy an element of an array to a standard Python scalar and return it. load()Manually trigger loading of this variable’s data from disk or a remote source into memory and return this variable. max([dim, axis, skipna])Reduce this Variable’s data by applying max along some dimension(s). mean([dim, axis, skipna])Reduce this Variable’s data by applying mean along some dimension(s). median([dim, axis, skipna])Reduce this Variable’s data by applying median along some dimension(s). min([dim, axis, skipna])Reduce this Variable’s data by applying min along some dimension(s). no_conflicts(other)True if the intersection of two Variable’s non-null data is equal; otherwise false. notnull(*args, **kwargs)pad_with_fill_value([pad_widths, fill_value])Return a new Variable with paddings. prod([dim, axis, skipna])Reduce this Variable’s data by applying prod along some dimension(s). quantile(q[, dim, interpolation])Compute the qth quantile of the data along the specified dimension. rank(dim[, pct])Ranks the data. reduce(func[, dim, axis, keep_attrs, allow_lazy])Reduce this array by applying func along some dimension(s). roll([shifts])Return a new Variable with rolld data. rolling_window(dim, window, window_dim[, …])Make a rolling_window along dim and add a new_dim to the last place. round(*args, **kwargs)searchsorted(v[, side, sorter])Find indices where elements of v should be inserted in a to maintain order. set_dims(dims[, shape])Return a new variable with given set of dimensions. shift([shifts, fill_value])Return a new Variable with shifted data. squeeze([dim])Return a new object with squeezed data. stack([dimensions])Stack any number of existing dimensions into a single new dimension. std([dim, axis, skipna])Reduce this Variable’s data by applying std along some dimension(s). sum([dim, axis, skipna])Reduce this Variable’s data by applying sum along some dimension(s). to_base_variable()Return this variable as a base xarray.Variable to_coord()to_coord has been deprecated. to_dict([data])Dictionary representation of variable. to_index()Convert this variable to a pandas.Index to_index_variable()Return this variable as an xarray.IndexVariable to_variable()to_variable has been deprecated. transpose(*dims)Return a new Variable object with transposed dimensions. unstack([dimensions])Unstack an existing dimension into multiple new dimensions. var([dim, axis, skipna])Reduce this Variable’s data by applying var along some dimension(s). where(cond[, other])Attributes
TattrsDictionary of local attributes on this variable. chunksBlock dimensions for this array’s data or None if it’s not a dask array. datadimsTuple of dimension names with which this variable is associated. dtypeencodingDictionary of encodings on this variable. imaglevel_namesReturn MultiIndex level names or None if this IndexVariable has no MultiIndex. namenbytesndimrealshapesizesizesOrdered mapping from dimension names to lengths. valuesThe variable’s data as a numpy.ndarray -