@docsubst<EOL><INDENT>@stat_1d<EOL>def var(self, expression, binby=[], limits=None, shape=default_shape, selection=False, delay=False, progress=None):<DEDENT>
expression = _ensure_strings_from_expressions(expression)<EOL>@delayed<EOL>def calculate(expression, limits):<EOL><INDENT>task = tasks.TaskStatistic(self, binby, shape, limits, weight=expression, op=tasks.OP_ADD_WEIGHT_MOMENTS_012, selection=selection)<EOL>progressbar.add_task(task, "<STR_LIT>" % expression)<EOL>self.executor.schedule(task)<EOL>return task<EOL><DEDENT>@delayed<EOL>def finish(*stats_args):<EOL><INDENT>stats = np.array(stats_args)<EOL>counts = stats[..., <NUM_LIT:0>]<EOL>with np.errstate(divide='<STR_LIT:ignore>'):<EOL><INDENT>with np.errstate(divide='<STR_LIT:ignore>', invalid='<STR_LIT:ignore>'):  <EOL><INDENT>mean = stats[..., <NUM_LIT:1>] / counts<EOL>raw_moments2 = stats[..., <NUM_LIT:2>] / counts<EOL><DEDENT><DEDENT>variance = (raw_moments2 - mean**<NUM_LIT:2>)<EOL>return vaex.utils.unlistify(waslist, variance)<EOL><DEDENT>binby = _ensure_strings_from_expressions(binby)<EOL>waslist, [expressions, ] = vaex.utils.listify(expression)<EOL>progressbar = vaex.utils.progressbars(progress)<EOL>limits = self.limits(binby, limits, delay=True)<EOL>stats = [calculate(expression, limits) for expression in expressions]<EOL>var = finish(*stats)<EOL>return self._delay(delay, var)<EOL>
Calculate the sample variance for the given expression, possible on a grid defined by binby

        Example:

        >>> df.var("vz")
        12170.002429456246
        >>> df.var("vz", binby=["(x**2+y**2)**0.5"], shape=4)
        array([ 15271.90481083,   7284.94713504,   3738.52239232,   1449.63418988])
        >>> df.var("vz", binby=["(x**2+y**2)**0.5"], shape=4)**0.5
        array([ 123.57954851,   85.35190177,   61.14345748,   38.0740619 ])
        >>> df.std("vz", binby=["(x**2+y**2)**0.5"], shape=4)
        array([ 123.57954851,   85.35190177,   61.14345748,   38.0740619 ])

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