{"library":"xarray","title":"Xarray","description":"Xarray (pronounced 'ex-array') is an open-source Python package that simplifies working with labelled multi-dimensional arrays and datasets. It introduces labels in the form of dimensions, coordinates, and attributes on top of raw NumPy-like arrays, enabling a more intuitive and less error-prone experience for scientific computing and data analysis, particularly for earth sciences. As of February 2026, the current version is 2026.2.0. Xarray maintains a regular release cadence, with minor versions typically released monthly or bi-monthly.","status":"active","version":"2026.2.0","language":"en","source_language":"en","source_url":"https://github.com/pydata/xarray","tags":["data analysis","scientific computing","netcdf","zarr","labeled arrays","multidimensional","geospatial"],"install":[{"cmd":"pip install xarray","lang":"bash","label":"Core installation"},{"cmd":"pip install \"xarray[complete]\"","lang":"bash","label":"Full installation with all optional dependencies"}],"dependencies":[{"reason":"Core requirement","package":"python","min_version":"3.11"},{"reason":"Required for core array operations","package":"numpy","min_version":"1.26"},{"reason":"Required for core data structures and compatibility","package":"pandas","min_version":"2.2"},{"reason":"Required for dependency version management","package":"packaging","min_version":"24.1"},{"reason":"Optional, for parallel and out-of-core computing","package":"dask","optional":true},{"reason":"Optional, recommended for reading and writing NetCDF files","package":"netCDF4","optional":true},{"reason":"Optional, for accelerating NaN-skipping and rolling window aggregations","package":"bottleneck","optional":true},{"reason":"Optional, for chunked, compressed, N-dimensional arrays","package":"zarr","optional":true},{"reason":"Optional, for plotting capabilities","package":"matplotlib","optional":true}],"imports":[{"symbol":"DataArray","correct":"import xarray as xr; da = xr.DataArray(...)"},{"symbol":"Dataset","correct":"import xarray as xr; ds = xr.Dataset(...)"},{"note":"The library was renamed from 'xray' to 'xarray' in January 2016. The 'xray' module no longer exists.","wrong":"import xray as xr","symbol":"xray","correct":"import xarray as xr"}],"quickstart":{"code":"import xarray as xr\nimport numpy as np\nimport pandas as pd\n\n# Create a DataArray\ndata_array = xr.DataArray(\n    np.random.rand(2, 3),\n    coords={\"x\": [10, 20], \"y\": [\"a\", \"b\", \"c\"]},\n    dims=(\"x\", \"y\"),\n    name=\"random_data\"\n)\n\n# Create a Dataset with two DataArrays sharing coordinates\ntemp = xr.DataArray(\n    25 + 10 * np.random.randn(2, 3, 4),\n    coords={\n        \"time\": pd.to_datetime([\"2026-01-01\", \"2026-01-02\"]),\n        \"lat\": [40, 50],\n        \"lon\": [100, 110, 120, 130]\n    },\n    dims=(\"time\", \"lat\", \"lon\"),\n    name=\"temperature\",\n    attrs={\"units\": \"Celsius\", \"long_name\": \"Air Temperature\"}\n)\n\nprecip = xr.DataArray(\n    5 * np.random.rand(2, 3, 4),\n    coords=temp.coords, # Share coordinates from temp\n    dims=temp.dims,\n    name=\"precipitation\",\n    attrs={\"units\": \"mm\", \"long_name\": \"Precipitation Rate\"}\n)\n\ndataset = xr.Dataset({\"temp\": temp, \"precip\": precip})\n\n# Perform a simple operation (e.g., mean over 'time' dimension)\nmean_temp = dataset[\"temp\"].mean(dim=\"time\")\n\nprint(\"DataArray:\\n\", data_array)\nprint(\"\\nDataset:\\n\", dataset)\nprint(\"\\nMean temperature over time:\\n\", mean_temp)","lang":"python","description":"This quickstart demonstrates the creation of a basic `DataArray` and a `Dataset`, including dimension names, coordinates, and attributes. It then shows how to perform a simple aggregation (mean) on a variable within the `Dataset` along a specified dimension."},"warnings":[{"fix":"Review code that relies on attributes being dropped by default. If the old behavior is desired, explicitly set `keep_attrs=False` or manually manage attributes.","message":"Default attribute preservation behavior changed in `xarray` v2025.11.0. All operations now preserve attributes by default. Previously, attributes were dropped unless `keep_attrs=True` was explicitly set. Binary operations now combine attributes using `drop_conflicts` instead of keeping only the left operand's attributes.","severity":"breaking","affected_versions":">=2025.11.0"},{"fix":"Explicitly convert the `DataArray` to a NumPy array using `.values` before applying the NumPy ufunc (e.g., `np.add.reduce(da.values)`).","message":"Direct application of certain NumPy ufuncs to `xarray.DataArray` objects may now raise `NotImplementedError` due to the `__array_ufunc__` protocol. This affects ufuncs that previously implicitly converted `DataArray` to a NumPy array.","severity":"breaking","affected_versions":">=0.10.2"},{"fix":"If only data identity is required, compare the underlying data (`.values` or by casting to `pandas.DataFrame`). Adjust identity checks if index differences are now considered relevant.","message":"The behavior of `Dataset.identical()`, `DataArray.identical()`, and `testing.assert_identical()` changed to include comparison of indexes. Two objects with identical data but different indexes will no longer be considered identical.","severity":"breaking","affected_versions":">=2026.2.0"}],"env_vars":null,"last_verified":"2026-04-05T00:00:00.000Z","next_check":"2026-07-04T00:00:00.000Z"}