MCPcopy Index your code
hub / github.com/pydata/xarray / head

Method head

xarray/core/dataarray.py:1737–1778  ·  view source on GitHub ↗

Return a new DataArray whose data is given by the first `n` values along the specified dimension(s). Default `n` = 5 See Also -------- Dataset.head DataArray.tail DataArray.thin Examples -------- >>> da = xr.DataArray(

(
        self,
        indexers: Mapping[Any, int] | int | None = None,
        **indexers_kwargs: Any,
    )

Source from the content-addressed store, hash-verified

1735 return self._from_temp_dataset(ds)
1736
1737 def head(
1738 self,
1739 indexers: Mapping[Any, int] | int | None = None,
1740 **indexers_kwargs: Any,
1741 ) -> Self:
1742 """Return a new DataArray whose data is given by the first `n`
1743 values along the specified dimension(s). Default `n` = 5
1744
1745 See Also
1746 --------
1747 Dataset.head
1748 DataArray.tail
1749 DataArray.thin
1750
1751 Examples
1752 --------
1753 >>> da = xr.DataArray(
1754 ... np.arange(25).reshape(5, 5),
1755 ... dims=("x", "y"),
1756 ... )
1757 >>> da
1758 <xarray.DataArray (x: 5, y: 5)> Size: 200B
1759 array([[ 0, 1, 2, 3, 4],
1760 [ 5, 6, 7, 8, 9],
1761 [10, 11, 12, 13, 14],
1762 [15, 16, 17, 18, 19],
1763 [20, 21, 22, 23, 24]])
1764 Dimensions without coordinates: x, y
1765
1766 >>> da.head(x=1)
1767 <xarray.DataArray (x: 1, y: 5)> Size: 40B
1768 array([[0, 1, 2, 3, 4]])
1769 Dimensions without coordinates: x, y
1770
1771 >>> da.head({"x": 2, "y": 2})
1772 <xarray.DataArray (x: 2, y: 2)> Size: 32B
1773 array([[0, 1],
1774 [5, 6]])
1775 Dimensions without coordinates: x, y
1776 """
1777 ds = self._to_temp_dataset().head(indexers, **indexers_kwargs)
1778 return self._from_temp_dataset(ds)
1779
1780 def tail(
1781 self,

Callers

nothing calls this directly

Calls 2

_to_temp_datasetMethod · 0.95
_from_temp_datasetMethod · 0.95

Tested by

no test coverage detected