DataArray#
DataArray([data, coords, dims, name, attrs, ...])
N-dimensional array with labeled coordinates and dimensions.
Attributes#
The array's data converted to numpy.ndarray.
The DataArray's data as an array.
Mapping of DataArray objects corresponding to coordinate variables.
Tuple of dimension names associated with this array.
Ordered mapping from dimension names to lengths.
The name of this array.
Dictionary storing arbitrary metadata with this array.
Dictionary of format-specific settings for how this array should be serialized.
Mapping of pandas.Index objects used for label based indexing.
Mapping of Index objects used for label based indexing.
Mapping from dimension names to block lengths for this dataarray's data.
ndarray attributes#
Number of array dimensions.
Total bytes consumed by the elements of this DataArray's data.
Tuple of array dimensions.
Number of elements in the array.
Data-type of the array’s elements.
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, dimensions 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_indexes(coord_names, *[, errors])
Drop the indexes assigned to the given coordinates.
DataArray.drop_duplicates(dim, *[, keep])
Returns a new DataArray with duplicate dimension values removed.
Return a new DataArray without encoding on the array or any attached coords.
DataArray.drop_attrs(*[, deep])
Removes all attributes from the DataArray.
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.__setitem__(key, value)
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 first n values along the specified dimension(s).
DataArray.tail([indexers])
Return a new DataArray whose data is given by 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, for indexes which the objects share.
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), 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, attributes, attributes on all coordinates, and indexes.
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 DataArrayGroupBy object for performing grouped operations.
DataArray.groupby_bins(group, bins[, right, ...])
Returns a DataArrayGroupBy object for performing grouped operations.
DataArray.rolling([dim, min_periods, center])
Rolling window object for DataArrays.
DataArray.rolling_exp([window, window_type])
Exponentially-weighted moving window.
DataArray.cumulative(dim[, min_periods])
Accumulating object for DataArrays.
DataArray.weighted(weights)
Weighted DataArray operations.
DataArray.coarsen([dim, boundary, side, ...])
Coarsen object for DataArrays.
DataArray.resample([indexer, skipna, ...])
Returns a Resample object for performing resampling operations.
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 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, skipna, keep_attrs])
Reduce this DataArray's data by applying cumsum along some dimension(s).
DataArray.cumprod([dim, skipna, keep_attrs])
Reduce this DataArray's data by applying cumprod along some dimension(s).
ndarray methods#
DataArray.argsort([axis, kind, order, stable])
Returns the indices that would sort this array.
DataArray.clip([min, max, keep_attrs])
Return an array whose values are limited to [min, max].
Complex-conjugate all elements.
DataArray.conjugate(*args, **kwargs)
a.conj()
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)
The real part of the array.
DataArray.rank(dim, *[, pct, keep_attrs])
Ranks the data.
String manipulation#
Convert strings in the array to be capitalized.
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.
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].
Check whether all characters in each string are alphanumeric.
Check whether all characters in each string are alphabetic.
Check whether all characters in each string are decimal.
Check whether all characters in each string are digits.
Check whether all characters in each string are lowercase.
Check whether all characters in each string are numeric.
Check whether all characters in each string are spaces.
Check whether all characters in each string are titlecase.
Check whether all characters in each string are uppercase.
DataArray.str.join([dim, sep])
Concatenate strings in a DataArray along a particular dimension.
Compute the length of each string in the array.
DataArray.str.ljust(width[, fillchar])
Pad right side of each string in the array.
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.
Test if the start of each string in the array matches a pattern.
DataArray.str.strip([to_strip, side])
Remove leading and trailing characters.
Convert strings in the array to be swapcased.
Convert strings in the array to titlecase.
DataArray.str.translate(table)
Map characters of each string through the given mapping table.
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:
The year of the datetime
The month as January=1, December=12
The days of the datetime
The hours of the datetime
The minutes of the datetime
The seconds of the datetime
The microseconds of the datetime
The nanoseconds of the datetime
The day of the week with Monday=0, Sunday=6
The day of the week with Monday=0, Sunday=6
The ordinal day of the year
The quarter of the date
The number of days in the month
The number of days in the month
Each datetime as the year plus the fraction of the year elapsed.
Season of the year
Timestamps corresponding to datetimes
Date corresponding to datetimes
Convert the dates as a fractional year.
The name of the calendar of the dates.
Indicate whether the date is the first day of the month
Indicate whether the date is the last day of the month
Indicate whether the date is the last day of a quarter
Indicate whether the date is the first day of a 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.
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:
Number of days for each element
Number of seconds (>= 0 and less than 1 day) for each element
Number of microseconds (>= 0 and less than 1 second) for each element
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(*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 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.