MCPcopy Create free account
hub / github.com/pydata/xarray / cumsum

Method cumsum

xarray/namedarray/_aggregations.py:775–847  ·  view source on GitHub ↗

Reduce this NamedArray's data by applying ``cumsum`` along some dimension(s). Parameters ---------- dim : str, Iterable of Hashable, "..." or None, default: None Name of dimension[s] along which to apply ``cumsum``. For e.g. ``dim="x"`` or ``

(
        self,
        dim: Dims = None,
        *,
        skipna: bool | None = None,
        **kwargs: Any,
    )

Source from the content-addressed store, hash-verified

773 )
774
775 def cumsum(
776 self,
777 dim: Dims = None,
778 *,
779 skipna: bool | None = None,
780 **kwargs: Any,
781 ) -> Self:
782 """
783 Reduce this NamedArray's data by applying ``cumsum`` along some dimension(s).
784
785 Parameters
786 ----------
787 dim : str, Iterable of Hashable, "..." or None, default: None
788 Name of dimension[s] along which to apply ``cumsum``. For e.g. ``dim="x"``
789 or ``dim=["x", "y"]``. If "..." or None, will reduce over all dimensions.
790 skipna : bool or None, optional
791 If True, skip missing values (as marked by NaN). By default, only
792 skips missing values for float dtypes; other dtypes either do not
793 have a sentinel missing value (int) or ``skipna=True`` has not been
794 implemented (object, datetime64 or timedelta64).
795 **kwargs : Any
796 Additional keyword arguments passed on to the appropriate array
797 function for calculating ``cumsum`` on this object's data.
798 These could include dask-specific kwargs like ``split_every``.
799
800 Returns
801 -------
802 reduced : NamedArray
803 New NamedArray with ``cumsum`` applied to its data and the
804 indicated dimension(s) removed
805
806 See Also
807 --------
808 numpy.cumsum
809 dask.array.cumsum
810 Dataset.cumsum
811 DataArray.cumsum
812 NamedArray.cumulative
813 :ref:`agg`
814 User guide on reduction or aggregation operations.
815
816 Notes
817 -----
818 Non-numeric variables will be removed prior to reducing.
819
820 Note that the methods on the ``cumulative`` method are more performant (with numbagg installed)
821 and better supported. ``cumsum`` and ``cumprod`` may be deprecated
822 in the future.
823
824 Examples
825 --------
826 >>> from xarray.namedarray.core import NamedArray
827 >>> na = NamedArray("x", np.array([1, 2, 3, 0, 2, np.nan]))
828 >>> na
829 <xarray.NamedArray (x: 6)> Size: 48B
830 array([ 1., 2., 3., 0., 2., nan])
831
832 >>> na.cumsum()

Callers

nothing calls this directly

Calls 1

reduceMethod · 0.95

Tested by

no test coverage detected