A multi-dimensional, in memory, array database.
A dataset resembles an in-memory representation of a NetCDF file,and consists of variables, coordinates and attributes whichtogether form a self describing dataset.
Dataset implements the mapping interface with keys given by variablenames and values given by DataArray objects for each variable name.
By default, pandas indexes are created for one dimensional variables withname equal to their dimension (i.e., Dimension coordinate) so thosevariables can be readily used as coordinates for label based indexing. When aCoordinates
object is passed to coords
, any existingindex(es) built from those coordinates will be added to the Dataset.
To load data from a file or file-like object, use the open_datasetfunction.
In this example dataset, we will represent measurements of the temperatureand pressure that were made under various conditions:
>>> np.random.seed(0)>>> temperature = 15 + 8 * np.random.randn(2, 3, 4)>>> precipitation = 10 * np.random.rand(2, 3, 4)>>> lon = [-99.83, -99.32]>>> lat = [42.25, 42.21]>>> instruments = ["manufac1", "manufac2", "manufac3"]>>> time = pd.date_range("2014-09-06", periods=4)>>> reference_time = pd.Timestamp("2014-09-05")
Here, we initialize the dataset with multiple dimensions. We use the string“loc” to represent the location dimension of the data, the string“instrument” to represent the instrument manufacturer dimension, and thestring “time” for the time dimension.
>>> ds = xr.Dataset(... data_vars=dict(... temperature=(["loc", "instrument", "time"], temperature),... precipitation=(["loc", "instrument", "time"], precipitation),... ),... coords=dict(... lon=("loc", lon),... lat=("loc", lat),... instrument=instruments,... time=time,... reference_time=reference_time,... ),... attrs=dict(description="Weather related data."),... )>>> ds<xarray.Dataset> Size: 552BDimensions: (loc: 2, instrument: 3, time: 4)Coordinates: lon (loc) float64 16B -99.83 -99.32 lat (loc) float64 16B 42.25 42.21 * instrument (instrument) <U8 96B 'manufac1' 'manufac2' 'manufac3' * time (time) datetime64[ns] 32B 2014-09-06 ... 2014-09-09 reference_time datetime64[ns] 8B 2014-09-05Dimensions without coordinates: locData variables: temperature (loc, instrument, time) float64 192B 29.11 18.2 ... 9.063 precipitation (loc, instrument, time) float64 192B 4.562 5.684 ... 1.613Attributes: description: Weather related data.
Find out where the coldest temperature was and what values theother variables had:
__init__([data_vars,coords,attrs]) | |
| Reduce this Dataset's data by applying |
| Reduce this Dataset's data by applying |
| Backward compatible implementation of |
| Indices of the maxima of the member variables. |
| Indices of the minima of the member variables. |
| Returns the indices that would sort this array. |
| Coerces wrapped data and coordinates into numpy arrays, returning a Dataset. |
| Assign new data variables to a Dataset, returning a new object with all the original variables in addition to the new ones. |
| Assign new attrs to this object. |
| Assign new coordinates to this object. |
| Copy of the xarray object, with data cast to a specified type. |
| Fill NaN values by propagating values backward |
| Two Datasets are broadcast equal if they are equal after broadcasting all variables against each other. |
| Broadcast this DataArray against another Dataset or DataArray. |
| Coerce all arrays in this dataset into dask arrays with the given chunks. |
| Return an array whose values are limited to |
| Release any resources linked to this object. |
| Coarsen object for Datasets. |
| Combine two Datasets, default to data_vars of self. |
| Manually trigger loading and/or computation of this dataset's data from disk or a remote source into memory and return a new dataset. |
| Complex-conjugate all elements. |
Return the complex conjugate, element-wise. | |
| Convert the Dataset to another calendar. |
| Returns a copy of this dataset. |
| Reduce this Dataset's data by applying |
| Reduce this Dataset's data by applying |
| Reduce this Dataset's data by applying |
| Accumulating object for Datasets |
| Integrate along the given coordinate using the trapezoidal rule. |
| Curve fitting optimization for arbitrary functions. |
| Calculate the n-th order discrete difference along given axis. |
| Differentiate with the second order accurate central differences. |
| Backward compatible method based on drop_vars and drop_sel |
| Drop dimensions and associated variables from this dataset. |
| Returns a new Dataset with duplicate dimension values removed. |
Return a new Dataset without encoding on the dataset or any of its variables/coords. | |
| Drop the indexes assigned to the given coordinates. |
| Drop index positions from this Dataset. |
| Drop index labels from this dataset. |
| Drop variables from this dataset. |
| Returns a new dataset with dropped labels for missing values along the provided dimension. |
| Store dataset contents to a backends.*DataStore object. |
| Two Datasets are equal if they have matching variables and coordinates, all of which are equal. |
| Calculate an expression supplied as a string in the context of the dataset. |
| Return a new object with an additional axis (or axes) inserted at the corresponding position in the array shape. |
| Fill NaN values by propagating values forward |
| Fill missing values in this object. |
| Returns a |
| Convert a pandas.DataFrame into an xarray.Dataset |
| Convert a dictionary into an xarray.Dataset. |
| |
| Get an index for a dimension, with fall-back to a default RangeIndex |
| Returns a DatasetGroupBy object for performing grouped operations. |
| Returns a DatasetGroupBy object for performing grouped operations. |
| Returns a new dataset with the first n values of each array for the specified dimension(s). |
| Like equals, but also checks all dataset attributes and the attributes on all variables and coordinates. |
| Return the coordinate label of the maximum value along a dimension. |
| Return the coordinate label of the minimum value along a dimension. |
| Concise summary of a Dataset variables and attributes. |
| Integrate along the given coordinate using the trapezoidal rule. |
| Interpolate a Dataset onto new coordinates |
| Interpolates the Dataset to another calendar based on decimal year measure. |
| Interpolate this object onto the coordinates of another object, filling the out of range values with NaN. |
| Fill in NaNs by interpolating according to different methods. |
| Returns a new dataset with each array indexed along the specified dimension(s). |
| Tests each value in the array for whether it is in test elements. |
| Test each value in the array for whether it is a missing value. |
| |
| |
| Manually trigger loading and/or computation of this dataset's data from disk or a remote source into memory and return this dataset. |
| Create a new dataset from the contents of a backends.*DataStore object |
| Apply a function to each data variable in this dataset |
| Apply a function to each block of this Dataset. |
| Reduce this Dataset's data by applying |
| Reduce this Dataset's data by applying |
| Reduce this Dataset's data by applying |
| Merge the arrays of two datasets into a single dataset. |
| Reduce this Dataset's data by applying |
| Test each value in the array for whether it is not a missing value. |
| Pad this dataset along one or more dimensions. |
| Trigger computation, keeping data as dask arrays |
| Apply |
| Least squares polynomial fit. |
| Reduce this Dataset's data by applying |
| Compute the qth quantile of the data along the specified dimension. |
| 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. |
| Ranks the data. |
| Reduce this dataset by applying func along some dimension(s). |
| Conform this object onto a new set of indexes, filling in missing values with |
| Conform this object onto the indexes of another object, for indexes which the objects share. |
| Returns a new object with renamed variables, coordinates and dimensions. |
| Returns a new object with renamed dimensions only. |
| Returns a new object with renamed variables including coordinates |
| Rearrange index levels using input order. |
| Returns a Resample object for performing resampling operations. |
| Given names of coordinates, reset them to become variables |
| |
| Reset the specified index(es) or multi-index level(s). |
| Roll this dataset by an offset along one or more dimensions. |
| Rolling window object for Datasets. |
| Exponentially-weighted moving window. |
| Round an array to the given number of decimals. |
| Returns a new dataset with each array indexed by tick labels along the specified dimension(s). |
| Register the function that releases any resources linked to this object. |
| Given names of one or more variables, set them as coordinates |
| Set Dataset (multi-)indexes using one or more existing coordinates or variables. |
| Set a new, Xarray-compatible index from one or more existing coordinate(s). |
| Shift this dataset by an offset along one or more dimensions. |
| Sort object by labels or values (along an axis). |
| Return a new object with squeezed data. |
| Stack any number of existing dimensions into a single new dimension. |
| Reduce this Dataset's data by applying |
| Reduce this Dataset's data by applying |
| Returns a new object with swapped dimensions. |
| Returns a new dataset with the last n values of each array for the specified dimension(s). |
| Returns a new dataset with each array indexed along every n-th value for the specified dimension(s) |
| Deprecated version of to_dataarray |
| Convert this dataset into a dask.dataframe.DataFrame. |
| Convert this dataset into an xarray.DataArray |
| Convert this dataset into a pandas.DataFrame. |
| Convert this dataset to a dictionary following xarray naming conventions. |
| Write dataset contents to a netCDF file. |
Convert this dataset into a pandas object without changing the number of dimensions. | |
| Combine variables of differing dimensionality into a DataArray without broadcasting. |
| Write dataset contents to a zarr group. |
| Return a new Dataset object with all array dimensions transposed. |
Unify chunk size along all chunked dimensions of this Dataset. | |
| Unstack existing dimensions corresponding to MultiIndexes into multiple new dimensions. |
| Update this dataset's variables with those from another dataset. |
| |
| Reduce this Dataset's data by applying |
| Weighted Dataset operations. |
| Filter elements from this object according to a condition. |