API reference#

This page provides an auto-generated summary of xarray’s API. For more details and examples, refer to the relevant chapters in the main part of the documentation.

See also: What parts of xarray are considered public API?

Top-level functions#

apply_ufunc(func, *args[, input_core_dims, ...])

Apply a vectorized function for unlabeled arrays on xarray objects.

align(*objects[, join, copy, indexes, ...])

Given any number of Dataset and/or DataArray objects, returns new objects with aligned indexes and dimension sizes.

broadcast(*args[, exclude])

Explicitly broadcast any number of DataArray or Dataset objects against one another.

concat(objs, dim[, data_vars, coords, ...])

Concatenate xarray objects along a new or existing dimension.

merge(objects[, compat, join, fill_value, ...])

Merge any number of xarray objects into a single Dataset as variables.

combine_by_coords([data_objects, compat, ...])

Attempt to auto-magically combine the given datasets (or data arrays) into one by using dimension coordinates.

combine_nested(datasets, concat_dim[, ...])

Explicitly combine an N-dimensional grid of datasets into one by using a succession of concat and merge operations along each dimension of the grid.

where(cond, x, y[, keep_attrs])

Return elements from x or y depending on cond.

infer_freq(index)

Infer the most likely frequency given the input index.

full_like(other, fill_value[, dtype])

Return a new object with the same shape and type as a given object.

zeros_like(other[, dtype])

Return a new object of zeros with the same shape and type as a given dataarray or dataset.

ones_like(other[, dtype])

Return a new object of ones with the same shape and type as a given dataarray or dataset.

cov(da_a, da_b[, dim, ddof])

Compute covariance between two DataArray objects along a shared dimension.

corr(da_a, da_b[, dim])

Compute the Pearson correlation coefficient between two DataArray objects along a shared dimension.

cross(a, b, *, dim)

Compute the cross product of two (arrays of) vectors.

dot(*arrays[, dims])

Generalized dot product for xarray objects.

polyval(coord, coeffs[, degree_dim])

Evaluate a polynomial at specific values

map_blocks(func, obj[, args, kwargs, template])

Apply a function to each block of a DataArray or Dataset.

show_versions([file])

print the versions of xarray and its dependencies

set_options(**kwargs)

Set options for xarray in a controlled context.

get_options()

Get options for xarray.

unify_chunks(*objects)

Given any number of Dataset and/or DataArray objects, returns new objects with unified chunk size along all chunked dimensions.

Dataset#

Creating a dataset#

Dataset([data_vars, coords, attrs])

A multi-dimensional, in memory, array database.

decode_cf(obj[, concat_characters, ...])

Decode the given Dataset or Datastore according to CF conventions into a new Dataset.

Attributes#

Dataset.dims

Mapping from dimension names to lengths.

Dataset.sizes

Mapping from dimension names to lengths.

Dataset.dtypes

Mapping from data variable names to dtypes.

Dataset.data_vars

Dictionary of DataArray objects corresponding to data variables

Dataset.coords

Dictionary of xarray.DataArray objects corresponding to coordinate variables

Dataset.attrs

Dictionary of global attributes on this dataset

Dataset.encoding

Dictionary of global encoding attributes on this dataset

Dataset.indexes

Mapping of pandas.Index objects used for label based indexing.

Dataset.chunks

Mapping from dimension names to block lengths for this dataset's data, or None if the underlying data is not a dask array.

Dataset.chunksizes

Mapping from dimension names to block lengths for this dataset's data, or None if the underlying data is not a dask array.

Dataset.nbytes

Dictionary interface#

Datasets implement the mapping interface with keys given by variable names and values given by DataArray objects.

Dataset.__getitem__(key)

Access variables or coordinates of this dataset as a DataArray or a subset of variables or a indexed dataset.

Dataset.__setitem__(key, value)

Add an array to this dataset.

Dataset.__delitem__(key)

Remove a variable from this dataset.

Dataset.update(other)

Update this dataset's variables with those from another dataset.

Dataset.get(k[,d])

Dataset.items()

Dataset.keys()

Dataset.values()

Dataset contents#

Dataset.copy([deep, data])

Returns a copy of this dataset.

Dataset.assign([variables])

Assign new data variables to a Dataset, returning a new object with all the original variables in addition to the new ones.

Dataset.assign_coords([coords])

Assign new coordinates to this object.

Dataset.assign_attrs(*args, **kwargs)

Assign new attrs to this object.

Dataset.pipe(func, *args, **kwargs)

Apply func(self, *args, **kwargs)

Dataset.merge(other[, overwrite_vars, ...])

Merge the arrays of two datasets into a single dataset.

Dataset.rename([name_dict])

Returns a new object with renamed variables and dimensions.

Dataset.rename_vars([name_dict])

Returns a new object with renamed variables including coordinates

Dataset.rename_dims([dims_dict])

Returns a new object with renamed dimensions only.

Dataset.swap_dims([dims_dict])

Returns a new object with swapped dimensions.

Dataset.expand_dims([dim, axis])

Return a new object with an additional axis (or axes) inserted at the corresponding position in the array shape.

Dataset.drop_vars(names, *[, errors])

Drop variables from this dataset.

Dataset.drop_duplicates(dim[, keep])

Returns a new Dataset with duplicate dimension values removed.

Dataset.drop_dims(drop_dims, *[, errors])

Drop dimensions and associated variables from this dataset.

Dataset.set_coords(names)

Given names of one or more variables, set them as coordinates

Dataset.reset_coords([names, drop])

Given names of coordinates, reset them to become variables

Dataset.convert_calendar(calendar[, dim, ...])

Convert the Dataset to another calendar.

Dataset.interp_calendar(target[, dim])

Interpolates the Dataset to another calendar based on decimal year measure.

Dataset.get_index(key)

Get an index for a dimension, with fall-back to a default RangeIndex

Comparisons#

Dataset.equals(other)

Two Datasets are equal if they have matching variables and coordinates, all of which are equal.

Dataset.identical(other)

Like equals, but also checks all dataset attributes and the attributes on all variables and coordinates.

Dataset.broadcast_equals(other)

Two Datasets are broadcast equal if they are equal after broadcasting all variables against each other.

Indexing#

Dataset.loc

Attribute for location based indexing.

Dataset.isel([indexers, drop, missing_dims])

Returns a new dataset with each array indexed along the specified dimension(s).

Dataset.sel([indexers, method, tolerance, drop])

Returns a new dataset with each array indexed by tick labels along the specified dimension(s).

Dataset.drop_sel([labels, errors])

Drop index labels from this dataset.

Dataset.drop_isel([indexers])

Drop index positions from this Dataset.

Dataset.head([indexers])

Returns a new dataset with the first n values of each array for the specified dimension(s).

Dataset.tail([indexers])

Returns a new dataset with the last n values of each array for the specified dimension(s).

Dataset.thin([indexers])

Returns a new dataset with each array indexed along every n-th value for the specified dimension(s)

Dataset.squeeze([dim, drop, axis])

Return a new object with squeezed data.

Dataset.interp([coords, method, ...])

Interpolate a Dataset onto new coordinates

Dataset.interp_like(other[, method, ...])

Interpolate this object onto the coordinates of another object, filling the out of range values with NaN.

Dataset.reindex([indexers, method, ...])

Conform this object onto a new set of indexes, filling in missing values with fill_value.

Dataset.reindex_like(other[, method, ...])

Conform this object onto the indexes of another object, filling in missing values with fill_value.

Dataset.set_index([indexes, append])

Set Dataset (multi-)indexes using one or more existing coordinates or variables.

Dataset.reset_index(dims_or_levels[, drop])

Reset the specified index(es) or multi-index level(s).

Dataset.reorder_levels([dim_order])

Rearrange index levels using input order.

Dataset.query([queries, parser, engine, ...])

Return a new dataset with each array indexed along the specified dimension(s), where the indexers are given as strings containing Python expressions to be evaluated against the data variables in the dataset.

Missing value handling#

Dataset.isnull([keep_attrs])

Test each value in the array for whether it is a missing value.

Dataset.notnull([keep_attrs])

Test each value in the array for whether it is not a missing value.

Dataset.combine_first(other)

Combine two Datasets, default to data_vars of self.

Dataset.count([dim, keep_attrs])

Reduce this Dataset's data by applying count along some dimension(s).

Dataset.dropna(dim[, how, thresh, subset])

Returns a new dataset with dropped labels for missing values along the provided dimension.

Dataset.fillna(value)

Fill missing values in this object.

Dataset.ffill(dim[, limit])

Fill NaN values by propagating values forward

Dataset.bfill(dim[, limit])

Fill NaN values by propagating values backward

Dataset.interpolate_na([dim, method, limit, ...])

Fill in NaNs by interpolating according to different methods.

Dataset.where(cond[, other, drop])

Filter elements from this object according to a condition.

Dataset.isin(test_elements)

Tests each value in the array for whether it is in test elements.

Computation#

Dataset.map(func[, keep_attrs, args])

Apply a function to each data variable in this dataset

Dataset.reduce(func[, dim, keep_attrs, ...])

Reduce this dataset by applying func along some dimension(s).

Dataset.groupby(group[, squeeze, ...])

Returns a GroupBy object for performing grouped operations.

Dataset.groupby_bins(group, bins[, right, ...])

Returns a GroupBy object for performing grouped operations.

Dataset.rolling([dim, min_periods, center])

Rolling window object.

Dataset.rolling_exp([window, window_type])

Exponentially-weighted moving window.

Dataset.weighted(weights)

Weighted operations.

Dataset.coarsen([dim, boundary, side, ...])

Coarsen object.

Dataset.resample([indexer, skipna, closed, ...])

Returns a Resample object for performing resampling operations.

Dataset.diff(dim[, n, label])

Calculate the n-th order discrete difference along given axis.

Dataset.quantile(q[, dim, method, ...])

Compute the qth quantile of the data along the specified dimension.

Dataset.differentiate(coord[, edge_order, ...])

Differentiate with the second order accurate central differences.

Dataset.integrate(coord[, datetime_unit])

Integrate along the given coordinate using the trapezoidal rule.

Dataset.map_blocks(func[, args, kwargs, ...])

Apply a function to each block of this Dataset.

Dataset.polyfit(dim, deg[, skipna, rcond, ...])

Least squares polynomial fit.

Dataset.curvefit(coords, func[, ...])

Curve fitting optimization for arbitrary functions.

Aggregation#

Dataset.all([dim, keep_attrs])

Reduce this Dataset's data by applying all along some dimension(s).

Dataset.any([dim, keep_attrs])

Reduce this Dataset's data by applying any along some dimension(s).

Dataset.argmax([dim])

Indices of the maxima of the member variables.

Dataset.argmin([dim])

Indices of the minima of the member variables.

Dataset.count([dim, keep_attrs])

Reduce this Dataset's data by applying count along some dimension(s).

Dataset.idxmax([dim, skipna, fill_value, ...])

Return the coordinate label of the maximum value along a dimension.

Dataset.idxmin([dim, skipna, fill_value, ...])

Return the coordinate label of the minimum value along a dimension.

Dataset.max([dim, skipna, keep_attrs])

Reduce this Dataset's data by applying max along some dimension(s).

Dataset.min([dim, skipna, keep_attrs])

Reduce this Dataset's data by applying min along some dimension(s).

Dataset.mean([dim, skipna, keep_attrs])

Reduce this Dataset's data by applying mean along some dimension(s).

Dataset.median([dim, skipna, keep_attrs])

Reduce this Dataset's data by applying median along some dimension(s).

Dataset.prod([dim, skipna, min_count, ...])

Reduce this Dataset's data by applying prod along some dimension(s).

Dataset.sum([dim, skipna, min_count, keep_attrs])

Reduce this Dataset's data by applying sum along some dimension(s).

Dataset.std([dim, skipna, ddof, keep_attrs])

Reduce this Dataset's data by applying std along some dimension(s).

Dataset.var([dim, skipna, ddof, keep_attrs])

Reduce this Dataset's data by applying var along some dimension(s).

Dataset.cumsum([dim, skipna])

Apply cumsum along some dimension of Dataset.

Dataset.cumprod([dim, skipna])

Apply cumprod along some dimension of Dataset.

ndarray methods#

Dataset.argsort([axis, kind, order])

Returns the indices that would sort this array.

Dataset.astype(dtype, *[, order, casting, ...])

Copy of the xarray object, with data cast to a specified type.

Dataset.clip([min, max, keep_attrs])

Return an array whose values are limited to [min, max].

Dataset.conj()

Complex-conjugate all elements.

Dataset.conjugate()

Return the complex conjugate, element-wise.

Dataset.imag

Dataset.round(*args, **kwargs)

Evenly round to the given number of decimals.

Dataset.real

Dataset.rank(dim[, pct, keep_attrs])

Ranks the data.

Reshaping and reorganizing#

Dataset.transpose(*dims[, missing_dims])

Return a new Dataset object with all array dimensions transposed.

Dataset.stack([dimensions, create_index, ...])

Stack any number of existing dimensions into a single new dimension.

Dataset.unstack([dim, fill_value, sparse])

Unstack existing dimensions corresponding to MultiIndexes into multiple new dimensions.

Dataset.to_stacked_array(new_dim, sample_dims)

Combine variables of differing dimensionality into a DataArray without broadcasting.

Dataset.shift([shifts, fill_value])

Shift this dataset by an offset along one or more dimensions.

Dataset.roll([shifts, roll_coords])

Roll this dataset by an offset along one or more dimensions.

Dataset.pad([pad_width, mode, stat_length, ...])

Pad this dataset along one or more dimensions.

Dataset.sortby(variables[, ascending])

Sort object by labels or values (along an axis).

Dataset.broadcast_like(other[, exclude])

Broadcast this DataArray against another Dataset or DataArray.

Plotting#

Dataset.plot.scatter(x, y, ax, **kwargs)

Scatter Dataset data variables against each other.

Dataset.plot.quiver(x, y, ax, u, v, **kwargs)

Quiver plot of Dataset variables.

Dataset.plot.streamplot(x, y, ax, u, v, **kwargs)

Plot streamlines of Dataset variables.

DataArray#

DataArray([data, coords, dims, name, attrs, ...])

N-dimensional array with labeled coordinates and dimensions.

Attributes#

DataArray.values

The array's data as a numpy.ndarray.

DataArray.data

The DataArray's data as an array.

DataArray.coords

Dictionary-like container of coordinate arrays.

DataArray.dims

Tuple of dimension names associated with this array.

DataArray.sizes

Ordered mapping from dimension names to lengths.

DataArray.name

The name of this array.

DataArray.attrs

Dictionary storing arbitrary metadata with this array.

DataArray.encoding

Dictionary of format-specific settings for how this array should be serialized.

DataArray.indexes

Mapping of pandas.Index objects used for label based indexing.

DataArray.chunksizes

Mapping from dimension names to block lengths for this dataarray's data, or None if the underlying data is not a dask array.

ndarray attributes#

DataArray.ndim

DataArray.nbytes

DataArray.shape

DataArray.size

DataArray.dtype

DataArray.nbytes

DataArray.chunks

Tuple of block lengths for this dataarray's data, in order of dimensions, or None if the underlying data is not a dask array.

DataArray contents#

DataArray.assign_coords([coords])

Assign new coordinates to this object.

DataArray.assign_attrs(*args, **kwargs)

Assign new attrs to this object.

DataArray.pipe(func, *args, **kwargs)

Apply func(self, *args, **kwargs)

DataArray.rename([new_name_or_name_dict])

Returns a new DataArray with renamed coordinates or a new name.

DataArray.swap_dims([dims_dict])

Returns a new DataArray with swapped dimensions.

DataArray.expand_dims([dim, axis])

Return a new object with an additional axis (or axes) inserted at the corresponding position in the array shape.

DataArray.drop_vars(names, *[, errors])

Returns an array with dropped variables.

DataArray.drop_duplicates(dim[, keep])

Returns a new DataArray with duplicate dimension values removed.

DataArray.reset_coords([names, drop])

Given names of coordinates, reset them to become variables.

DataArray.copy([deep, data])

Returns a copy of this array.

DataArray.convert_calendar(calendar[, dim, ...])

Convert the DataArray to another calendar.

DataArray.interp_calendar(target[, dim])

Interpolates the DataArray to another calendar based on decimal year measure.

DataArray.get_index(key)

Get an index for a dimension, with fall-back to a default RangeIndex

DataArray.astype(dtype, *[, order, casting, ...])

Copy of the xarray object, with data cast to a specified type.

DataArray.item(*args)

Copy an element of an array to a standard Python scalar and return it.

Indexing#

DataArray.__getitem__(key)

DataArray.__setitem__(key, value)

DataArray.loc

Attribute for location based indexing like pandas.

DataArray.isel([indexers, drop, missing_dims])

Return a new DataArray whose data is given by selecting indexes along the specified dimension(s).

DataArray.sel([indexers, method, tolerance, ...])

Return a new DataArray whose data is given by selecting index labels along the specified dimension(s).

DataArray.drop_sel([labels, errors])

Drop index labels from this DataArray.

DataArray.drop_isel([indexers])

Drop index positions from this DataArray.

DataArray.head([indexers])

Return a new DataArray whose data is given by the the first n values along the specified dimension(s).

DataArray.tail([indexers])

Return a new DataArray whose data is given by the the last n values along the specified dimension(s).

DataArray.thin([indexers])

Return a new DataArray whose data is given by each n value along the specified dimension(s).

DataArray.squeeze([dim, drop, axis])

Return a new object with squeezed data.

DataArray.interp([coords, method, ...])

Interpolate a DataArray onto new coordinates

DataArray.interp_like(other[, method, ...])

Interpolate this object onto the coordinates of another object, filling out of range values with NaN.

DataArray.reindex([indexers, method, ...])

Conform this object onto the indexes of another object, filling in missing values with fill_value.

DataArray.reindex_like(other[, method, ...])

Conform this object onto the indexes of another object, filling in missing values with fill_value.

DataArray.set_index([indexes, append])

Set DataArray (multi-)indexes using one or more existing coordinates.

DataArray.reset_index(dims_or_levels[, drop])

Reset the specified index(es) or multi-index level(s).

DataArray.reorder_levels([dim_order])

Rearrange index levels using input order.

DataArray.query([queries, parser, engine, ...])

Return a new data array indexed along the specified dimension(s), where the indexers are given as strings containing Python expressions to be evaluated against the values in the array.

Missing value handling#

DataArray.isnull([keep_attrs])

Test each value in the array for whether it is a missing value.

DataArray.notnull([keep_attrs])

Test each value in the array for whether it is not a missing value.

DataArray.combine_first(other)

Combine two DataArray objects, with union of coordinates.

DataArray.count([dim, keep_attrs])

Reduce this DataArray's data by applying count along some dimension(s).

DataArray.dropna(dim[, how, thresh])

Returns a new array with dropped labels for missing values along the provided dimension.

DataArray.fillna(value)

Fill missing values in this object.

DataArray.ffill(dim[, limit])

Fill NaN values by propagating values forward

DataArray.bfill(dim[, limit])

Fill NaN values by propagating values backward

DataArray.interpolate_na([dim, method, ...])

Fill in NaNs by interpolating according to different methods.

DataArray.where(cond[, other, drop])

Filter elements from this object according to a condition.

DataArray.isin(test_elements)

Tests each value in the array for whether it is in test elements.

Comparisons#

DataArray.equals(other)

True if two DataArrays have the same dimensions, coordinates and values; otherwise False.

DataArray.identical(other)

Like equals, but also checks the array name and attributes, and attributes on all coordinates.

DataArray.broadcast_equals(other)

Two DataArrays are broadcast equal if they are equal after broadcasting them against each other such that they have the same dimensions.

Computation#

DataArray.reduce(func[, dim, axis, ...])

Reduce this array by applying func along some dimension(s).

DataArray.groupby(group[, squeeze, ...])

Returns a GroupBy object for performing grouped operations.

DataArray.groupby_bins(group, bins[, right, ...])

Returns a GroupBy object for performing grouped operations.

DataArray.rolling([dim, min_periods, center])

Rolling window object.

DataArray.rolling_exp([window, window_type])

Exponentially-weighted moving window.

DataArray.weighted(weights)

Weighted operations.

DataArray.coarsen([dim, boundary, side, ...])

Coarsen object.

DataArray.resample([indexer, skipna, ...])

Returns a Resample object for performing resampling operations.

DataArray.get_axis_num(dim)

Return axis number(s) corresponding to dimension(s) in this array.

DataArray.diff(dim[, n, label])

Calculate the n-th order discrete difference along given axis.

DataArray.dot(other[, dims])

Perform dot product of two DataArrays along their shared dims.

DataArray.quantile(q[, dim, method, ...])

Compute the qth quantile of the data along the specified dimension.

DataArray.differentiate(coord[, edge_order, ...])

Differentiate the array with the second order accurate central differences.

DataArray.integrate([coord, datetime_unit])

Integrate along the given coordinate using the trapezoidal rule.

DataArray.polyfit(dim, deg[, skipna, rcond, ...])

Least squares polynomial fit.

DataArray.map_blocks(func[, args, kwargs, ...])

Apply a function to each block of this DataArray.

DataArray.curvefit(coords, func[, ...])

Curve fitting optimization for arbitrary functions.

Aggregation#

DataArray.all([dim, keep_attrs])

Reduce this DataArray's data by applying all along some dimension(s).

DataArray.any([dim, keep_attrs])

Reduce this DataArray's data by applying any along some dimension(s).

DataArray.argmax([dim, axis, keep_attrs, skipna])

Index or indices of the maximum of the DataArray over one or more dimensions.

DataArray.argmin([dim, axis, keep_attrs, skipna])

Index or indices of the minimum of the DataArray over one or more dimensions.

DataArray.count([dim, keep_attrs])

Reduce this DataArray's data by applying count along some dimension(s).

DataArray.idxmax([dim, skipna, fill_value, ...])

Return the coordinate label of the maximum value along a dimension.

DataArray.idxmin([dim, skipna, fill_value, ...])

Return the coordinate label of the minimum value along a dimension.

DataArray.max([dim, skipna, keep_attrs])

Reduce this DataArray's data by applying max along some dimension(s).

DataArray.min([dim, skipna, keep_attrs])

Reduce this DataArray's data by applying min along some dimension(s).

DataArray.mean([dim, skipna, keep_attrs])

Reduce this DataArray's data by applying mean along some dimension(s).

DataArray.median([dim, skipna, keep_attrs])

Reduce this DataArray's data by applying median along some dimension(s).

DataArray.prod([dim, skipna, min_count, ...])

Reduce this DataArray's data by applying prod along some dimension(s).

DataArray.sum([dim, skipna, min_count, ...])

Reduce this DataArray's data by applying sum along some dimension(s).

DataArray.std([dim, skipna, ddof, keep_attrs])

Reduce this DataArray's data by applying std along some dimension(s).

DataArray.var([dim, skipna, ddof, keep_attrs])

Reduce this DataArray's data by applying var along some dimension(s).

DataArray.cumsum([dim, axis, skipna])

Apply cumsum along some dimension of DataArray.

DataArray.cumprod([dim, axis, skipna])

Apply cumprod along some dimension of DataArray.

ndarray methods#

DataArray.argsort([axis, kind, order])

Returns the indices that would sort this array.

DataArray.clip([min, max, keep_attrs])

Return an array whose values are limited to [min, max].

DataArray.conj()

Complex-conjugate all elements.

DataArray.conjugate()

Return the complex conjugate, element-wise.

DataArray.imag

DataArray.searchsorted(v[, side, sorter])

Find indices where elements of v should be inserted in a to maintain order.

DataArray.round(*args, **kwargs)

Evenly round to the given number of decimals.

DataArray.real

DataArray.T

DataArray.rank(dim[, pct, keep_attrs])

Ranks the data.

String manipulation#

DataArray.str

DataArray.str.capitalize()

Convert strings in the array to be capitalized.

DataArray.str.casefold()

Convert strings in the array to be casefolded.

DataArray.str.cat(*others[, sep])

Concatenate strings elementwise in the DataArray with other strings.

DataArray.str.center(width[, fillchar])

Pad left and right side of each string in the array.

DataArray.str.contains(pat[, case, flags, regex])

Test if pattern or regex is contained within each string of the array.

DataArray.str.count(pat[, flags, case])

Count occurrences of pattern in each string of the array.

DataArray.str.decode(encoding[, errors])

Decode character string in the array using indicated encoding.

DataArray.str.encode(encoding[, errors])

Encode character string in the array using indicated encoding.

DataArray.str.endswith(pat)

Test if the end of each string in the array matches a pattern.

DataArray.str.extract(pat, dim[, case, flags])

Extract the first match of capture groups in the regex pat as a new dimension in a DataArray.

DataArray.str.extractall(pat, group_dim, ...)

Extract all matches of capture groups in the regex pat as new dimensions in a DataArray.

DataArray.str.find(sub[, start, end, side])

Return lowest or highest indexes in each strings in the array where the substring is fully contained between [start:end].

DataArray.str.findall(pat[, case, flags])

Find all occurrences of pattern or regular expression in the DataArray.

DataArray.str.format(*args, **kwargs)

Perform python string formatting on each element of the DataArray.

DataArray.str.get(i[, default])

Extract character number i from each string in the array.

DataArray.str.get_dummies(dim[, sep])

Return DataArray of dummy/indicator variables.

DataArray.str.index(sub[, start, end, side])

Return lowest or highest indexes in each strings where the substring is fully contained between [start:end].

DataArray.str.isalnum()

Check whether all characters in each string are alphanumeric.

DataArray.str.isalpha()

Check whether all characters in each string are alphabetic.

DataArray.str.isdecimal()

Check whether all characters in each string are decimal.

DataArray.str.isdigit()

Check whether all characters in each string are digits.

DataArray.str.islower()

Check whether all characters in each string are lowercase.

DataArray.str.isnumeric()

Check whether all characters in each string are numeric.

DataArray.str.isspace()

Check whether all characters in each string are spaces.

DataArray.str.istitle()

Check whether all characters in each string are titlecase.

DataArray.str.isupper()

Check whether all characters in each string are uppercase.

DataArray.str.join([dim, sep])

Concatenate strings in a DataArray along a particular dimension.

DataArray.str.len()

Compute the length of each string in the array.

DataArray.str.ljust(width[, fillchar])

Pad right side of each string in the array.

DataArray.str.lower()

Convert strings in the array to lowercase.

DataArray.str.lstrip([to_strip])

Remove leading characters.

DataArray.str.match(pat[, case, flags])

Determine if each string in the array matches a regular expression.

DataArray.str.normalize(form)

Return the Unicode normal form for the strings in the datarray.

DataArray.str.pad(width[, side, fillchar])

Pad strings in the array up to width.

DataArray.str.partition(dim[, sep])

Split the strings in the DataArray at the first occurrence of separator sep.

DataArray.str.repeat(repeats)

Repeat each string in the array.

DataArray.str.replace(pat, repl[, n, case, ...])

Replace occurrences of pattern/regex in the array with some string.

DataArray.str.rfind(sub[, start, end])

Return highest indexes in each strings in the array where the substring is fully contained between [start:end].

DataArray.str.rindex(sub[, start, end])

Return highest indexes in each strings where the substring is fully contained between [start:end].

DataArray.str.rjust(width[, fillchar])

Pad left side of each string in the array.

DataArray.str.rpartition(dim[, sep])

Split the strings in the DataArray at the last occurrence of separator sep.

DataArray.str.rsplit(dim[, sep, maxsplit])

Split strings in a DataArray around the given separator/delimiter sep.

DataArray.str.rstrip([to_strip])

Remove trailing characters.

DataArray.str.slice([start, stop, step])

Slice substrings from each string in the array.

DataArray.str.slice_replace([start, stop, repl])

Replace a positional slice of a string with another value.

DataArray.str.split(dim[, sep, maxsplit])

Split strings in a DataArray around the given separator/delimiter sep.

DataArray.str.startswith(pat)

Test if the start of each string in the array matches a pattern.

DataArray.str.strip([to_strip, side])

Remove leading and trailing characters.

DataArray.str.swapcase()

Convert strings in the array to be swapcased.

DataArray.str.title()

Convert strings in the array to titlecase.

DataArray.str.translate(table)

Map characters of each string through the given mapping table.

DataArray.str.upper()

Convert strings in the array to uppercase.

DataArray.str.wrap(width, **kwargs)

Wrap long strings in the array in paragraphs with length less than width.

DataArray.str.zfill(width)

Pad each string in the array by prepending '0' characters.

Datetimelike properties#

Datetime properties:

DataArray.dt.year

The year of the datetime

DataArray.dt.month

The month as January=1, December=12

DataArray.dt.day

The days of the datetime

DataArray.dt.hour

The hours of the datetime

DataArray.dt.minute

The minutes of the datetime

DataArray.dt.second

The seconds of the datetime

DataArray.dt.microsecond

The microseconds of the datetime

DataArray.dt.nanosecond

The nanoseconds of the datetime

DataArray.dt.dayofweek

The day of the week with Monday=0, Sunday=6

DataArray.dt.weekday

The day of the week with Monday=0, Sunday=6

DataArray.dt.weekday_name

The name of day in a week

DataArray.dt.dayofyear

The ordinal day of the year

DataArray.dt.quarter

The quarter of the date

DataArray.dt.days_in_month

The number of days in the month

DataArray.dt.daysinmonth

The number of days in the month

DataArray.dt.season

Season of the year

DataArray.dt.time

Timestamps corresponding to datetimes

DataArray.dt.date

Date corresponding to datetimes

DataArray.dt.calendar

The name of the calendar of the dates.

DataArray.dt.is_month_start

Indicate whether the date is the first day of the month

DataArray.dt.is_month_end

Indicate whether the date is the last day of the month

DataArray.dt.is_quarter_end

Indicate whether the date is the last day of a quarter

DataArray.dt.is_year_start

Indicate whether the date is the first day of a year

DataArray.dt.is_leap_year

Indicate if the date belongs to a leap year

Datetime methods:

DataArray.dt.floor(freq)

Round timestamps downward to specified frequency resolution.

DataArray.dt.ceil(freq)

Round timestamps upward to specified frequency resolution.

DataArray.dt.isocalendar()

Dataset containing ISO year, week number, and weekday.

DataArray.dt.round(freq)

Round timestamps to specified frequency resolution.

DataArray.dt.strftime(date_format)

Return an array of formatted strings specified by date_format, which supports the same string format as the python standard library.

Timedelta properties:

DataArray.dt.days

Number of days for each element

DataArray.dt.seconds

Number of seconds (>= 0 and less than 1 day) for each element

DataArray.dt.microseconds

Number of microseconds (>= 0 and less than 1 second) for each element

DataArray.dt.nanoseconds

Number of nanoseconds (>= 0 and less than 1 microsecond) for each element

Timedelta methods:

DataArray.dt.floor(freq)

Round timestamps downward to specified frequency resolution.

DataArray.dt.ceil(freq)

Round timestamps upward to specified frequency resolution.

DataArray.dt.round(freq)

Round timestamps to specified frequency resolution.

Reshaping and reorganizing#

DataArray.transpose(*dims[, ...])

Return a new DataArray object with transposed dimensions.

DataArray.stack([dimensions, create_index, ...])

Stack any number of existing dimensions into a single new dimension.

DataArray.unstack([dim, fill_value, sparse])

Unstack existing dimensions corresponding to MultiIndexes into multiple new dimensions.

DataArray.to_unstacked_dataset(dim[, level])

Unstack DataArray expanding to Dataset along a given level of a stacked coordinate.

DataArray.shift([shifts, fill_value])

Shift this DataArray by an offset along one or more dimensions.

DataArray.roll([shifts, roll_coords])

Roll this array by an offset along one or more dimensions.

DataArray.pad([pad_width, mode, ...])

Pad this array along one or more dimensions.

DataArray.sortby(variables[, ascending])

Sort object by labels or values (along an axis).

DataArray.broadcast_like(other[, exclude])

Broadcast this DataArray against another Dataset or DataArray.

Plotting#

DataArray.plot([row, col, col_wrap, ax, ...])

Default plot of DataArray using matplotlib.pyplot.

DataArray.plot.contourf(x, y, **kwargs)

Filled contour plot of 2D DataArray.

DataArray.plot.contour(x, y, **kwargs)

Contour plot of 2D DataArray.

DataArray.plot.hist([figsize, size, aspect, ...])

Histogram of DataArray.

DataArray.plot.imshow(x, y, **kwargs)

Image plot of 2D DataArray.

DataArray.plot.line(*args[, row, col, ...])

Line plot of DataArray values.

DataArray.plot.pcolormesh(x, y, **kwargs)

Pseudocolor plot of 2D DataArray.

DataArray.plot.step(*args[, where, ...])

Step plot of DataArray values.

DataArray.plot.surface(x, y, **kwargs)

Surface plot of 2D DataArray.

IO / Conversion#

Dataset methods#

open_dataset(filename_or_obj, *[, engine, ...])

Open and decode a dataset from a file or file-like object.

load_dataset(filename_or_obj, **kwargs)

Open, load into memory, and close a Dataset from a file or file-like object.

open_mfdataset(paths[, chunks, concat_dim, ...])

Open multiple files as a single dataset.

open_rasterio(filename[, parse_coordinates, ...])

Open a file with rasterio.

open_zarr(store[, group, synchronizer, ...])

Load and decode a dataset from a Zarr store.

Dataset.to_netcdf([path, mode, format, ...])

Write dataset contents to a netCDF file.

Dataset.to_pandas()

Convert this dataset into a pandas object without changing the number of dimensions.

Dataset.as_numpy()

Coerces wrapped data and coordinates into numpy arrays, returning a Dataset.

Dataset.to_zarr([store, chunk_store, mode, ...])

Write dataset contents to a zarr group.

save_mfdataset(datasets, paths[, mode, ...])

Write multiple datasets to disk as netCDF files simultaneously.

Dataset.to_array([dim, name])

Convert this dataset into an xarray.DataArray

Dataset.to_dataframe([dim_order])

Convert this dataset into a pandas.DataFrame.

Dataset.to_dask_dataframe([dim_order, set_index])

Convert this dataset into a dask.dataframe.DataFrame.

Dataset.to_dict([data, encoding])

Convert this dataset to a dictionary following xarray naming conventions.

Dataset.from_dataframe(dataframe[, sparse])

Convert a pandas.DataFrame into an xarray.Dataset

Dataset.from_dict(d)

Convert a dictionary into an xarray.Dataset.

Dataset.close()

Release any resources linked to this object.

Dataset.compute(**kwargs)

Manually trigger loading and/or computation of this dataset's data from disk or a remote source into memory and return a new dataset.

Dataset.persist(**kwargs)

Trigger computation, keeping data as dask arrays

Dataset.load(**kwargs)

Manually trigger loading and/or computation of this dataset's data from disk or a remote source into memory and return this dataset.

Dataset.chunk([chunks, name_prefix, token, ...])

Coerce all arrays in this dataset into dask arrays with the given chunks.

Dataset.unify_chunks()

Unify chunk size along all chunked dimensions of this Dataset.

Dataset.filter_by_attrs(**kwargs)

Returns a Dataset with variables that match specific conditions.

Dataset.info([buf])

Concise summary of a Dataset variables and attributes.

DataArray methods#

open_dataarray(filename_or_obj, *[, engine, ...])

Open an DataArray from a file or file-like object containing a single data variable.

load_dataarray(filename_or_obj, **kwargs)

Open, load into memory, and close a DataArray from a file or file-like object containing a single data variable.

DataArray.to_dataset([dim, name, promote_attrs])

Convert a DataArray to a Dataset.

DataArray.to_netcdf([path, mode, format, ...])

Write dataset contents to a netCDF file.

DataArray.to_pandas()

Convert this array into a pandas object with the same shape.

DataArray.to_series()

Convert this array into a pandas.Series.

DataArray.to_dataframe([name, dim_order])

Convert this array and its coordinates into a tidy pandas.DataFrame.

DataArray.to_numpy()

Coerces wrapped data to numpy and returns a numpy.ndarray.

DataArray.as_numpy()

Coerces wrapped data and coordinates into numpy arrays, returning a DataArray.

DataArray.to_index()

Convert this variable to a pandas.Index.

DataArray.to_masked_array([copy])

Convert this array into a numpy.ma.MaskedArray

DataArray.to_cdms2()

Convert this array into a cdms2.Variable

DataArray.to_iris()

Convert this array into a iris.cube.Cube

DataArray.from_iris(cube)

Convert a iris.cube.Cube into an xarray.DataArray

DataArray.to_dict([data, encoding])

Convert this xarray.DataArray into a dictionary following xarray naming conventions.

DataArray.from_series(series[, sparse])

Convert a pandas.Series into an xarray.DataArray.

DataArray.from_cdms2(variable)

Convert a cdms2.Variable into an xarray.DataArray

DataArray.from_dict(d)

Convert a dictionary into an xarray.DataArray

DataArray.close()

Release any resources linked to this object.

DataArray.compute(**kwargs)

Manually trigger loading of this array's data from disk or a remote source into memory and return a new array.

DataArray.persist(**kwargs)

Trigger computation in constituent dask arrays

DataArray.load(**kwargs)

Manually trigger loading of this array's data from disk or a remote source into memory and return this array.

DataArray.chunk([chunks, name_prefix, ...])

Coerce this array's data into a dask arrays with the given chunks.

DataArray.unify_chunks()

Unify chunk size along all chunked dimensions of this DataArray.

Coordinates objects#

core.coordinates.DataArrayCoordinates(dataarray)

Dictionary like container for DataArray coordinates.

core.coordinates.DatasetCoordinates(dataset)

Dictionary like container for Dataset coordinates.

GroupBy objects#

Dataset#

DatasetGroupBy(obj, group[, squeeze, ...])

DatasetGroupBy.map(func[, args, shortcut])

Apply a function to each Dataset in the group and concatenate them together into a new Dataset.

DatasetGroupBy.reduce(func[, dim, axis, ...])

Reduce the items in this group by applying func along some dimension(s).

DatasetGroupBy.assign(**kwargs)

Assign data variables by group.

DatasetGroupBy.assign_coords([coords])

Assign coordinates by group.

DatasetGroupBy.first([skipna, keep_attrs])

Return the first element of each group along the group dimension

DatasetGroupBy.last([skipna, keep_attrs])

Return the last element of each group along the group dimension

DatasetGroupBy.fillna(value)

Fill missing values in this object by group.

DatasetGroupBy.quantile(q[, dim, method, ...])

Compute the qth quantile over each array in the groups and concatenate them together into a new array.

DatasetGroupBy.where(cond[, other])

Return elements from self or other depending on cond.

DatasetGroupBy.all([dim, keep_attrs])

Reduce this Dataset's data by applying all along some dimension(s).

DatasetGroupBy.any([dim, keep_attrs])

Reduce this Dataset's data by applying any along some dimension(s).

DatasetGroupBy.count([dim, keep_attrs])

Reduce this Dataset's data by applying count along some dimension(s).

DatasetGroupBy.max([dim, skipna, keep_attrs])

Reduce this Dataset's data by applying max along some dimension(s).

DatasetGroupBy.mean([dim, skipna, keep_attrs])

Reduce this Dataset's data by applying mean along some dimension(s).

DatasetGroupBy.median([dim, skipna, keep_attrs])

Reduce this Dataset's data by applying median along some dimension(s).

DatasetGroupBy.min([dim, skipna, keep_attrs])

Reduce this Dataset's data by applying min along some dimension(s).

DatasetGroupBy.prod([dim, skipna, ...])

Reduce this Dataset's data by applying prod along some dimension(s).

DatasetGroupBy.std([dim, skipna, ddof, ...])

Reduce this Dataset's data by applying std along some dimension(s).

DatasetGroupBy.sum([dim, skipna, min_count, ...])

Reduce this Dataset's data by applying sum along some dimension(s).

DatasetGroupBy.var([dim, skipna, ddof, ...])

Reduce this Dataset's data by applying var along some dimension(s).

DatasetGroupBy.dims

DatasetGroupBy.groups

Mapping from group labels to indices.

DataArray#

DataArrayGroupBy(obj, group[, squeeze, ...])

DataArrayGroupBy.map(func[, shortcut, args])

Apply a function to each array in the group and concatenate them together into a new array.

DataArrayGroupBy.reduce(func[, dim, axis, ...])

Reduce the items in this group by applying func along some dimension(s).

DataArrayGroupBy.assign_coords([coords])

Assign coordinates by group.

DataArrayGroupBy.first([skipna, keep_attrs])

Return the first element of each group along the group dimension

DataArrayGroupBy.last([skipna, keep_attrs])

Return the last element of each group along the group dimension

DataArrayGroupBy.fillna(value)

Fill missing values in this object by group.

DataArrayGroupBy.quantile(q[, dim, method, ...])

Compute the qth quantile over each array in the groups and concatenate them together into a new array.

DataArrayGroupBy.where(cond[, other])

Return elements from self or other depending on cond.

DataArrayGroupBy.all([dim, keep_attrs])

Reduce this DataArray's data by applying all along some dimension(s).

DataArrayGroupBy.any([dim, keep_attrs])

Reduce this DataArray's data by applying any along some dimension(s).

DataArrayGroupBy.count([dim, keep_attrs])

Reduce this DataArray's data by applying count along some dimension(s).

DataArrayGroupBy.max([dim, skipna, keep_attrs])

Reduce this DataArray's data by applying max along some dimension(s).

DataArrayGroupBy.mean([dim, skipna, keep_attrs])

Reduce this DataArray's data by applying mean along some dimension(s).

DataArrayGroupBy.median([dim, skipna, ...])

Reduce this DataArray's data by applying median along some dimension(s).

DataArrayGroupBy.min([dim, skipna, keep_attrs])

Reduce this DataArray's data by applying min along some dimension(s).

DataArrayGroupBy.prod([dim, skipna, ...])

Reduce this DataArray's data by applying prod along some dimension(s).

DataArrayGroupBy.std([dim, skipna, ddof, ...])

Reduce this DataArray's data by applying std along some dimension(s).

DataArrayGroupBy.sum([dim, skipna, ...])

Reduce this DataArray's data by applying sum along some dimension(s).

DataArrayGroupBy.var([dim, skipna, ddof, ...])

Reduce this DataArray's data by applying var along some dimension(s).

DataArrayGroupBy.dims

DataArrayGroupBy.groups

Mapping from group labels to indices.

Rolling objects#

Dataset#

DatasetRolling(obj, windows[, min_periods, ...])

DatasetRolling.construct([window_dim, ...])

Convert this rolling object to xr.Dataset, where the window dimension is stacked as a new dimension

DatasetRolling.reduce(func[, keep_attrs])

Reduce the items in this group by applying func along some dimension(s).

DatasetRolling.argmax([keep_attrs])

Reduce this object's data windows by applying argmax along its dimension.

DatasetRolling.argmin([keep_attrs])

Reduce this object's data windows by applying argmin along its dimension.

DatasetRolling.count([keep_attrs])

Reduce this object's data windows by applying count along its dimension.

DatasetRolling.max([keep_attrs])

Reduce this object's data windows by applying max along its dimension.

DatasetRolling.mean([keep_attrs])

Reduce this object's data windows by applying mean along its dimension.

DatasetRolling.median([keep_attrs])

Reduce this object's data windows by applying median along its dimension.

DatasetRolling.min([keep_attrs])

Reduce this object's data windows by applying min along its dimension.

DatasetRolling.prod([keep_attrs])

Reduce this object's data windows by applying prod along its dimension.

DatasetRolling.std([keep_attrs])

Reduce this object's data windows by applying std along its dimension.

DatasetRolling.sum([keep_attrs])

Reduce this object's data windows by applying sum along its dimension.

DatasetRolling.var([keep_attrs])

Reduce this object's data windows by applying var along its dimension.

DataArray#

DataArrayRolling(obj, windows[, ...])

DataArrayRolling.construct([window_dim, ...])

Convert this rolling object to xr.DataArray, where the window dimension is stacked as a new dimension

DataArrayRolling.reduce(func[, keep_attrs])

Reduce the items in this group by applying func along some dimension(s).

DataArrayRolling.argmax([keep_attrs])

Reduce this object's data windows by applying argmax along its dimension.

DataArrayRolling.argmin([keep_attrs])

Reduce this object's data windows by applying argmin along its dimension.

DataArrayRolling.count([keep_attrs])

Reduce this object's data windows by applying count along its dimension.

DataArrayRolling.max([keep_attrs])

Reduce this object's data windows by applying max along its dimension.

DataArrayRolling.mean([keep_attrs])

Reduce this object's data windows by applying mean along its dimension.

DataArrayRolling.median([keep_attrs])

Reduce this object's data windows by applying median along its dimension.

DataArrayRolling.min([keep_attrs])

Reduce this object's data windows by applying min along its dimension.

DataArrayRolling.prod([keep_attrs])

Reduce this object's data windows by applying prod along its dimension.

DataArrayRolling.std([keep_attrs])

Reduce this object's data windows by applying std along its dimension.

DataArrayRolling.sum([keep_attrs])

Reduce this object's data windows by applying sum along its dimension.

DataArrayRolling.var([keep_attrs])

Reduce this object's data windows by applying var along its dimension.

Coarsen objects#

Dataset#

DatasetCoarsen(obj, windows, boundary, side, ...)

DatasetCoarsen.all([keep_attrs])

Reduce this DatasetCoarsen's data by applying all along some dimension(s).

DatasetCoarsen.any([keep_attrs])

Reduce this DatasetCoarsen's data by applying any along some dimension(s).

DatasetCoarsen.construct([window_dim, ...])

Convert this Coarsen object to a DataArray or Dataset, where the coarsening dimension is split or reshaped to two new dimensions.

DatasetCoarsen.count([keep_attrs])

Reduce this DatasetCoarsen's data by applying count along some dimension(s).

DatasetCoarsen.max([keep_attrs])

Reduce this DatasetCoarsen's data by applying max along some dimension(s).

DatasetCoarsen.mean([keep_attrs])

Reduce this DatasetCoarsen's data by applying mean along some dimension(s).

DatasetCoarsen.median([keep_attrs])

Reduce this DatasetCoarsen's data by applying median along some dimension(s).

DatasetCoarsen.min([keep_attrs])

Reduce this DatasetCoarsen's data by applying min along some dimension(s).

DatasetCoarsen.prod([keep_attrs])

Reduce this DatasetCoarsen's data by applying prod along some dimension(s).

DatasetCoarsen.reduce(func[, keep_attrs])

Reduce the items in this group by applying func along some dimension(s).

DatasetCoarsen.std([keep_attrs])

Reduce this DatasetCoarsen's data by applying std along some dimension(s).

DatasetCoarsen.sum([keep_attrs])

Reduce this DatasetCoarsen's data by applying sum along some dimension(s).

DatasetCoarsen.var([keep_attrs])

Reduce this DatasetCoarsen's data by applying var along some dimension(s).

DataArray#

DataArrayCoarsen(obj, windows, boundary, ...)

DataArrayCoarsen.all([keep_attrs])

Reduce this DataArrayCoarsen's data by applying all along some dimension(s).

DataArrayCoarsen.any([keep_attrs])

Reduce this DataArrayCoarsen's data by applying any along some dimension(s).

DataArrayCoarsen.construct([window_dim, ...])

Convert this Coarsen object to a DataArray or Dataset, where the coarsening dimension is split or reshaped to two new dimensions.

DataArrayCoarsen.count([keep_attrs])

Reduce this DataArrayCoarsen's data by applying count along some dimension(s).

DataArrayCoarsen.max([keep_attrs])

Reduce this DataArrayCoarsen's data by applying max along some dimension(s).

DataArrayCoarsen.mean([keep_attrs])

Reduce this DataArrayCoarsen's data by applying mean along some dimension(s).

DataArrayCoarsen.median([keep_attrs])

Reduce this DataArrayCoarsen's data by applying median along some dimension(s).

DataArrayCoarsen.min([keep_attrs])

Reduce this DataArrayCoarsen's data by applying min along some dimension(s).

DataArrayCoarsen.prod([keep_attrs])

Reduce this DataArrayCoarsen's data by applying prod along some dimension(s).

DataArrayCoarsen.reduce(func[, keep_attrs])

Reduce the items in this group by applying func along some dimension(s).

DataArrayCoarsen.std([keep_attrs])

Reduce this DataArrayCoarsen's data by applying std along some dimension(s).

DataArrayCoarsen.sum([keep_attrs])

Reduce this DataArrayCoarsen's data by applying sum along some dimension(s).

DataArrayCoarsen.var([keep_attrs])

Reduce this DataArrayCoarsen's data by applying var along some dimension(s).

Exponential rolling objects#

RollingExp(obj, windows[, window_type])

Exponentially-weighted moving window object.

RollingExp.mean([keep_attrs])

Exponentially weighted moving average.

RollingExp.sum([keep_attrs])

Exponentially weighted moving sum.

Weighted objects#

Dataset#

DatasetWeighted(obj, weights)

DatasetWeighted.mean([dim, skipna, keep_attrs])

Reduce this Dataset's data by a weighted mean along some dimension(s).

DatasetWeighted.quantile(q, *[, dim, ...])

Apply a weighted quantile to this Dataset's data along some dimension(s).

DatasetWeighted.sum([dim, skipna, keep_attrs])

Reduce this Dataset's data by a weighted sum along some dimension(s).

DatasetWeighted.std([dim, skipna, keep_attrs])

Reduce this Dataset's data by a weighted std along some dimension(s).

DatasetWeighted.var([dim, skipna, keep_attrs])

Reduce this Dataset's data by a weighted var along some dimension(s).

DatasetWeighted.sum_of_weights([dim, keep_attrs])

Calculate the sum of weights, accounting for missing values in the data.

DatasetWeighted.sum_of_squares([dim, ...])

Reduce this Dataset's data by a weighted sum_of_squares along some dimension(s).

DataArray#

DataArrayWeighted(obj, weights)

DataArrayWeighted.mean([dim, skipna, keep_attrs])

Reduce this Dataset's data by a weighted mean along some dimension(s).

DataArrayWeighted.quantile(q, *[, dim, ...])

Apply a weighted quantile to this Dataset's data along some dimension(s).

DataArrayWeighted.sum([dim, skipna, keep_attrs])

Reduce this Dataset's data by a weighted sum along some dimension(s).

DataArrayWeighted.std([dim, skipna, keep_attrs])

Reduce this Dataset's data by a weighted std along some dimension(s).

DataArrayWeighted.var([dim, skipna, keep_attrs])

Reduce this Dataset's data by a weighted var along some dimension(s).

DataArrayWeighted.sum_of_weights([dim, ...])

Calculate the sum of weights, accounting for missing values in the data.

DataArrayWeighted.sum_of_squares([dim, ...])

Reduce this Dataset's data by a weighted sum_of_squares along some dimension(s).

Resample objects#

Dataset#

DatasetResample(*args[, dim, resample_dim])

DatasetGroupBy object specialized to resampling a specified dimension

DatasetResample.asfreq()

Return values of original object at the new up-sampling frequency; essentially a re-index with new times set to NaN.

DatasetResample.backfill([tolerance])

Backward fill new values at up-sampled frequency.

DatasetResample.interpolate([kind])

Interpolate up-sampled data using the original data as knots.

DatasetResample.nearest([tolerance])

Take new values from nearest original coordinate to up-sampled frequency coordinates.

DatasetResample.pad([tolerance])

Forward fill new values at up-sampled frequency.

DatasetResample.all([dim, keep_attrs])

Reduce this Dataset's data by applying all along some dimension(s).

DatasetResample.any([dim, keep_attrs])

Reduce this Dataset's data by applying any along some dimension(s).

DatasetResample.apply(func[, args, shortcut])

Backward compatible implementation of map

DatasetResample.assign(**kwargs)

Assign data variables by group.

DatasetResample.assign_coords([coords])

Assign coordinates by group.

DatasetResample.bfill([tolerance])

Backward fill new values at up-sampled frequency.

DatasetResample.count([dim, keep_attrs])

Reduce this Dataset's data by applying count along some dimension(s).

DatasetResample.ffill([tolerance])

Forward fill new values at up-sampled frequency.

DatasetResample.fillna(value)

Fill missing values in this object by group.

DatasetResample.first([skipna, keep_attrs])

Return the first element of each group along the group dimension

DatasetResample.last([skipna, keep_attrs])

Return the last element of each group along the group dimension

DatasetResample.map(func[, args, shortcut])

Apply a function over each Dataset in the groups generated for resampling and concatenate them together into a new Dataset.

DatasetResample.max([dim, skipna, keep_attrs])

Reduce this Dataset's data by applying max along some dimension(s).

DatasetResample.mean([dim, skipna, keep_attrs])

Reduce this Dataset's data by applying mean along some dimension(s).

DatasetResample.median([dim, skipna, keep_attrs])

Reduce this Dataset's data by applying median along some dimension(s).

DatasetResample.min([dim, skipna, keep_attrs])

Reduce this Dataset's data by applying min along some dimension(s).

DatasetResample.prod([dim, skipna, ...])

Reduce this Dataset's data by applying prod along some dimension(s).

DatasetResample.quantile(q[, dim, method, ...])

Compute the qth quantile over each array in the groups and concatenate them together into a new array.

DatasetResample.reduce(func[, dim, axis, ...])

Reduce the items in this group by applying func along the pre-defined resampling dimension.

DatasetResample.std([dim, skipna, ddof, ...])

Reduce this Dataset's data by applying std along some dimension(s).

DatasetResample.sum([dim, skipna, ...])

Reduce this Dataset's data by applying sum along some dimension(s).

DatasetResample.var([dim, skipna, ddof, ...])

Reduce this Dataset's data by applying var along some dimension(s).

DatasetResample.where(cond[, other])

Return elements from self or other depending on cond.

DatasetResample.dims

DatasetResample.groups

Mapping from group labels to indices.

DataArray#

DataArrayResample(*args[, dim, resample_dim])

DataArrayGroupBy object specialized to time resampling operations over a specified dimension

DataArrayResample.asfreq()

Return values of original object at the new up-sampling frequency; essentially a re-index with new times set to NaN.

DataArrayResample.backfill([tolerance])

Backward fill new values at up-sampled frequency.

DataArrayResample.interpolate([kind])

Interpolate up-sampled data using the original data as knots.

DataArrayResample.nearest([tolerance])

Take new values from nearest original coordinate to up-sampled frequency coordinates.

DataArrayResample.pad([tolerance])

Forward fill new values at up-sampled frequency.

DataArrayResample.all([dim, keep_attrs])

Reduce this DataArray's data by applying all along some dimension(s).

DataArrayResample.any([dim, keep_attrs])

Reduce this DataArray's data by applying any along some dimension(s).

DataArrayResample.apply(func[, args, shortcut])

Backward compatible implementation of map

DataArrayResample.assign_coords([coords])

Assign coordinates by group.

DataArrayResample.bfill([tolerance])

Backward fill new values at up-sampled frequency.

DataArrayResample.count([dim, keep_attrs])

Reduce this DataArray's data by applying count along some dimension(s).

DataArrayResample.ffill([tolerance])

Forward fill new values at up-sampled frequency.

DataArrayResample.fillna(value)

Fill missing values in this object by group.

DataArrayResample.first([skipna, keep_attrs])

Return the first element of each group along the group dimension

DataArrayResample.last([skipna, keep_attrs])

Return the last element of each group along the group dimension

DataArrayResample.map(func[, shortcut, args])

Apply a function to each array in the group and concatenate them together into a new array.

DataArrayResample.max([dim, skipna, keep_attrs])

Reduce this DataArray's data by applying max along some dimension(s).

DataArrayResample.mean([dim, skipna, keep_attrs])

Reduce this DataArray's data by applying mean along some dimension(s).

DataArrayResample.median([dim, skipna, ...])

Reduce this DataArray's data by applying median along some dimension(s).

DataArrayResample.min([dim, skipna, keep_attrs])

Reduce this DataArray's data by applying min along some dimension(s).

DataArrayResample.prod([dim, skipna, ...])

Reduce this DataArray's data by applying prod along some dimension(s).

DataArrayResample.quantile(q[, dim, method, ...])

Compute the qth quantile over each array in the groups and concatenate them together into a new array.

DataArrayResample.reduce(func[, dim, axis, ...])

Reduce the items in this group by applying func along some dimension(s).

DataArrayResample.std([dim, skipna, ddof, ...])

Reduce this DataArray's data by applying std along some dimension(s).

DataArrayResample.sum([dim, skipna, ...])

Reduce this DataArray's data by applying sum along some dimension(s).

DataArrayResample.var([dim, skipna, ddof, ...])

Reduce this DataArray's data by applying var along some dimension(s).

DataArrayResample.where(cond[, other])

Return elements from self or other depending on cond.

DataArrayResample.dims

DataArrayResample.groups

Mapping from group labels to indices.

Accessors#

core.accessor_dt.DatetimeAccessor(obj)

Access datetime fields for DataArrays with datetime-like dtypes.

core.accessor_dt.TimedeltaAccessor(obj)

Access Timedelta fields for DataArrays with Timedelta-like dtypes.

core.accessor_str.StringAccessor(obj)

Vectorized string functions for string-like arrays.

Custom Indexes#

CFTimeIndex(data[, name])

Custom Index for working with CF calendars and dates

Creating custom indexes#

cftime_range([start, end, periods, freq, ...])

Return a fixed frequency CFTimeIndex.

date_range([start, end, periods, freq, tz, ...])

Return a fixed frequency datetime index.

date_range_like(source, calendar[, use_cftime])

Generate a datetime array with the same frequency, start and end as another one, but in a different calendar.

Faceting#

plot.FacetGrid(data[, col, row, col_wrap, ...])

Initialize the Matplotlib figure and FacetGrid object.

plot.FacetGrid.add_colorbar(**kwargs)

Draw a colorbar.

plot.FacetGrid.add_legend(**kwargs)

plot.FacetGrid.add_quiverkey(u, v, **kwargs)

plot.FacetGrid.map(func, *args, **kwargs)

Apply a plotting function to each facet's subset of the data.

plot.FacetGrid.map_dataarray(func, x, y, ...)

Apply a plotting function to a 2d facet's subset of the data.

plot.FacetGrid.map_dataarray_line(func, x, ...)

plot.FacetGrid.map_dataset(func[, x, y, ...])

plot.FacetGrid.set_axis_labels([x_var, y_var])

Set axis labels on the left column and bottom row of the grid.

plot.FacetGrid.set_ticks([max_xticks, ...])

Set and control tick behavior.

plot.FacetGrid.set_titles([template, ...])

Draw titles either above each facet or on the grid margins.

plot.FacetGrid.set_xlabels([label])

Label the x axis on the bottom row of the grid.

plot.FacetGrid.set_ylabels([label])

Label the y axis on the left column of the grid.

Tutorial#

tutorial.open_dataset(name[, cache, ...])

Open a dataset from the online repository (requires internet).

tutorial.open_rasterio(name[, engine, ...])

Open a rasterio dataset from the online repository (requires internet).

tutorial.load_dataset(*args, **kwargs)

Open, load into memory, and close a dataset from the online repository (requires internet).

Testing#

testing.assert_equal(a, b)

Like numpy.testing.assert_array_equal(), but for xarray objects.

testing.assert_identical(a, b)

Like xarray.testing.assert_equal(), but also matches the objects' names and attributes.

testing.assert_allclose(a, b[, rtol, atol, ...])

Like numpy.testing.assert_allclose(), but for xarray objects.

testing.assert_chunks_equal(a, b)

Assert that chunksizes along chunked dimensions are equal.

Exceptions#

MergeError

Error class for merge failures due to incompatible arguments.

SerializationWarning

Warnings about encoding/decoding issues in serialization.

Advanced API#

Dataset.variables

Low level interface to Dataset contents as dict of Variable objects.

DataArray.variable

Low level interface to the Variable object for this DataArray.

Variable(dims, data[, attrs, encoding, fastpath])

A netcdf-like variable consisting of dimensions, data and attributes which describe a single Array.

IndexVariable(dims, data[, attrs, encoding, ...])

Wrapper for accommodating a pandas.Index in an xarray.Variable.

as_variable(obj[, name])

Convert an object into a Variable.

Context(func)

object carrying the information of a call

register_dataset_accessor(name)

Register a custom property on xarray.Dataset objects.

register_dataarray_accessor(name)

Register a custom accessor on xarray.DataArray objects.

Dataset.set_close(close)

Register the function that releases any resources linked to this object.

backends.BackendArray()

backends.BackendEntrypoint()

BackendEntrypoint is a class container and it is the main interface for the backend plugins, see BackendEntrypoint subclassing.

These backends provide a low-level interface for lazily loading data from external file-formats or protocols, and can be manually invoked to create arguments for the load_store and dump_to_store Dataset methods:

backends.NetCDF4DataStore(manager[, group, ...])

Store for reading and writing data via the Python-NetCDF4 library.

backends.H5NetCDFStore(manager[, group, ...])

Store for reading and writing data via h5netcdf

backends.PydapDataStore(ds)

Store for accessing OpenDAP datasets with pydap.

backends.ScipyDataStore(filename_or_obj[, ...])

Store for reading and writing data via scipy.io.netcdf.

backends.FileManager()

Manager for acquiring and closing a file object.

backends.CachingFileManager(opener, *args[, ...])

Wrapper for automatically opening and closing file objects.

backends.DummyFileManager(value)

FileManager that simply wraps an open file in the FileManager interface.

Deprecated / Pending Deprecation#

Dataset.drop([labels, dim, errors])

Backward compatible method based on drop_vars and drop_sel

DataArray.drop([labels, dim, errors])

Backward compatible method based on drop_vars and drop_sel

Dataset.apply(func[, keep_attrs, args])

Backward compatible implementation of map

core.groupby.DataArrayGroupBy.apply(func[, ...])

Backward compatible implementation of map

core.groupby.DatasetGroupBy.apply(func[, ...])

Backward compatible implementation of map

DataArray.dt.weekofyear

The week ordinal of the year

DataArray.dt.week

The week ordinal of the year