DataArray#

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

N-dimensional array with labeled coordinates and dimensions.

Attributes#

DataArray.values

The array's data converted to numpy.ndarray.

DataArray.data

The DataArray's data as an array.

DataArray.coords

Mapping of DataArray objects for coordinates.

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 serializing this array.

DataArray.indexes

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

DataArray.xindexes

Mapping of Index objects for label indexing.

DataArray.chunksizes

Mapping from dimension names to block lengths for this dataarray's data.

ndarray attributes#

DataArray.ndim

Number of array dimensions.

DataArray.nbytes

Total bytes consumed by the elements of this DataArray's data.

DataArray.shape

Tuple of array dimensions.

DataArray.size

Number of elements in the array.

DataArray.dtype

Data-type of the array’s elements.

DataArray.chunks

Tuple of block lengths for this dataarray's data, in order of dimensions.

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])

Return a DataArray with renamed coordinates, dimensions or a new name.

DataArray.swap_dims([dims_dict])

Return a new DataArray with swapped dimensions.

DataArray.expand_dims([dim, axis, ...])

Return a new object with an additional axis (or axes) inserted.

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

Return an array with dropped variables.

DataArray.drop_indexes(coord_names, *[, errors])

Drop the indexes assigned to the given coordinates.

DataArray.drop_duplicates(dim, *[, keep])

Return a new DataArray with duplicate dimension values removed.

DataArray.drop_encoding()

Return a new DataArray without encoding on the array or any coords.

DataArray.drop_attrs(*[, deep])

Remove all attributes from the DataArray.

DataArray.reset_coords([names, drop])

Given names of coordinates, reset them to become variables.

DataArray.copy([deep, data])

Return 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, ...])

Return a 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 selecting indexes along the specified dimension(s).

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

Return a new DataArray selecting index labels along the given 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 with the first n values along given dimension(s).

DataArray.tail([indexers])

Return a new DataArray with the last n values along given dimension(s).

DataArray.thin([indexers])

Return a new DataArray with each n-th value along the given 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.

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

Conform this object onto a new set of indexes.

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

Conform this object onto the indexes of another object.

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.set_xindex(coord_names[, index_cls])

Set a new, Xarray-compatible index from one or more existing coordinate(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).

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])

Return a new array with dropped labels for missing values along a 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)

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

Comparisons#

DataArray.equals(other)

Check whether two DataArrays are equal.

DataArray.identical(other)

Check whether two DataArrays are identical.

DataArray.broadcast_equals(other)

Check whether two DataArrays are broadcast equal.

Computation#

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

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

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

Return a DataArrayGroupBy object for performing grouped operations.

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

Return a DataArrayGroupBy object for performing grouped operations.

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

Return a rolling window object for DataArrays.

DataArray.rolling_exp([window, window_type])

Exponentially-weighted moving window.

DataArray.cumulative(dim[, min_periods])

Return an accumulating object for DataArrays.

DataArray.weighted(weights)

Weighted DataArray operations.

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

Coarsen object for DataArrays.

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

Return 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[, dim])

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 one or more dimensions.

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

Return the coordinate label of the minimum value along one or more dimensions.

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

Reduce this DataArray's data by applying max (i.e., maximum) along some dimension(s).

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

Reduce this DataArray's data by applying min (i.e., minimum) 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 (i.e., product) 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 (i.e., standard deviation) along some dimension(s).

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

Reduce this DataArray's data by applying var (i.e., variance) along some dimension(s).

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

Reduce this DataArray's data by applying cumsum (i.e., cumulative sum) along some dimension(s).

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

Reduce this DataArray's data by applying cumprod (i.e., cumulative product) along some dimension(s).

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(*args, **kwargs)

a.conj()

DataArray.imag

The imaginary part of the array.

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

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

DataArray.round(*args, **kwargs)

DataArray.real

The real part of the array.

DataArray.T

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

Ranks the data.

String manipulation#

DataArray.str

Vectorized string functions for string-like arrays.

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.

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

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

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

Return lowest or highest indexes of a substring in each string in the array.

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 of a substring in each string in the array.

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 of a substring in each string in the array.

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

Return highest indexes of a substring in each string in the array.

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.day_of_week

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

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.day_of_year

The ordinal day of the year.

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.days_in_year

Each datetime as the year plus the fraction of the year elapsed.

DataArray.dt.season

Season of the year.

DataArray.dt.time

Timestamps corresponding to datetimes.

DataArray.dt.date

Date corresponding to datetimes.

DataArray.dt.decimal_year

Convert the dates as a fractional year.

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.

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.

DataArray.dt.total_seconds

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(*dim[, ...])

Return a new DataArray object with transposed dimensions.

DataArray.stack([dim, create_index, index_cls])

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

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

Unstack existing dimensions corresponding to MultiIndexes.

DataArray.to_unstacked_dataset(dim[, level])

Unstack DataArray to a Dataset along a 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.