@docsubst<EOL><INDENT>def covar(self, x, y, binby=[], limits=None, shape=default_shape, selection=False, delay=False, progress=None):<DEDENT>
@delayed<EOL>def cov(mean_x, mean_y, mean_xy):<EOL><INDENT>return mean_xy - mean_x * mean_y<EOL><DEDENT>waslist, [xlist, ylist] = vaex.utils.listify(x, y)<EOL>limits = self.limits(binby, limits, selection=selection, delay=True)<EOL>@delayed<EOL>def calculate(limits):<EOL><INDENT>results = []<EOL>for x, y in zip(xlist, ylist):<EOL><INDENT>mx = self.mean(x, binby=binby, limits=limits, shape=shape, selection=selection, delay=True, progress=progressbar)<EOL>my = self.mean(y, binby=binby, limits=limits, shape=shape, selection=selection, delay=True, progress=progressbar)<EOL>cxy = self.mean("<STR_LIT>" % (x, y), binby=binby, limits=limits, shape=shape, selection=selection,<EOL>delay=True, progress=progressbar)<EOL>results.append(cov(mx, my, cxy))<EOL><DEDENT>return results<EOL><DEDENT>progressbar = vaex.utils.progressbars(progress)<EOL>covars = calculate(limits)<EOL>@delayed<EOL>def finish(covars):<EOL><INDENT>value = np.array(vaex.utils.unlistify(waslist, covars))<EOL>return value<EOL><DEDENT>return self._delay(delay, finish(delayed_list(covars)))<EOL>
Calculate the covariance cov[x,y] between and x and y, possibly on a grid defined by binby.

        Example:

        >>> df.covar("x**2+y**2+z**2", "-log(-E+1)")
        array(52.69461456005138)
        >>> df.covar("x**2+y**2+z**2", "-log(-E+1)")/(df.std("x**2+y**2+z**2") * df.std("-log(-E+1)"))
        0.63666373822156686
        >>> df.covar("x**2+y**2+z**2", "-log(-E+1)", binby="Lz", shape=4)
        array([ 10.17387143,  51.94954078,  51.24902796,  20.2163929 ])



        :param x: {expression}
        :param y: {expression}
        :param binby: {binby}
        :param limits: {limits}
        :param shape: {shape}
        :param selection: {selection}
        :param delay: {delay}
        :param progress: {progress}
        :return: {return_stat_scalar}