Dataset.polyfit(dim, deg, skipna=None, rcond=None, w=None, full=False, cov=False)

Least squares polynomial fit.

This replicates the behaviour of numpy.polyfit but differs by skipping invalid values when skipna = True.

  • dim (hashable) – Coordinate along which to fit the polynomials.

  • deg (int) – Degree of the fitting polynomial.

  • skipna (bool, optional) – If True, removes all invalid values before fitting each 1D slices of the array. Default is True if data is stored in a dask.array or if there is any invalid values, False otherwise.

  • rcond (float, optional) – Relative condition number to the fit.

  • w (Union[Hashable, Any], optional) – Weights to apply to the y-coordinate of the sample points. Can be an array-like object or the name of a coordinate in the dataset.

  • full (bool, optional) – Whether to return the residuals, matrix rank and singular values in addition to the coefficients.

  • cov (Union[bool, str], optional) – Whether to return to the covariance matrix in addition to the coefficients. The matrix is not scaled if cov=’unscaled’.


polyfit_results – A single dataset which contains (for each “var” in the input dataset):


The coefficients of the best fit for each variable in this dataset.


The residuals of the least-square computation for each variable (only included if full=True)


The effective rank of the scaled Vandermonde coefficient matrix (only included if full=True)


The singular values of the scaled Vandermonde coefficient matrix (only included if full=True)


The covariance matrix of the polynomial coefficient estimates (only included if full=False and cov=True)

Return type


See also