Ejemplo n.º 1
0
    def min(self):
        """
        name:	min

        desc:
            The lowest numeric value in the column, or NAN if there
            are no numeric values.
        """

        n = self._numbers
        if not len(n):
            return CallableFloat(NAN)
        return CallableFloat(min(n))
Ejemplo n.º 2
0
    def sum(self):
        """
        name:	sum

        desc:
            The sum of all values in the column, or NAN if there
            are no numeric values.
        """

        n = self._numbers
        if not len(n):
            return NAN
        return CallableFloat(sum(n))
Ejemplo n.º 3
0
    def max(self):
        """
        name:	max

        desc:
            The highest numeric value in the column, or NAN if there
            are no numeric values.
        """

        n = self._numbers
        if not len(n):
            return NAN
        return CallableFloat(max(n))
Ejemplo n.º 4
0
    def mean(self):
        """
        name:	mean

        desc:
            Arithmetic mean of all values. If there are non-numeric values,
            these are ignored. If there are no numeric values, NAN is
            returned.
        """

        n = self._numbers
        if len(n) == 0:
            return NAN
        return CallableFloat(sum(n) / len(n))
Ejemplo n.º 5
0
    def std(self):
        """
        name:	std

        desc:
            The standard deviation of all values. If there are non-numeric
            values, these are ignored. If there are 0 or 1 numeric values, NAN
            is returned. The degrees of freedom are N-1.
        """

        m = self.mean
        n = self._numbers
        if len(n) <= 1:
            return NAN
        return CallableFloat(
            math.sqrt(sum((i - m)**2 for i in n) / (len(n) - 1)))
Ejemplo n.º 6
0
    def median(self):
        """
        name:	median

        desc:
            The median of all values. If there are non-numeric values,
            these are ignored. If there are no numeric values, NAN is
            returned.
        """

        n = sorted(self._numbers)
        if len(n) == 0:
            return NAN
        i = int(len(n) / 2)
        if len(n) % 2 == 1:
            return n[i]
        return CallableFloat(.5 * n[i] + .5 * n[i - 1])
    def sum(self):

        if not len(self._seq):
            return CallableFloat(np.nan)
        return CallableFloat(np.nansum(self._seq))
    def max(self):

        if not len(self._seq):
            return CallableFloat(np.nan)
        return CallableFloat(np.nanmax(self._seq))
    def std(self):

        # By default, ddof=0. The more normal calculation is to use ddof=1, so
        # we change that here. See also:
        # - http://stackoverflow.com/questions/27600207
        return CallableFloat(nanstd(self._seq, ddof=1))
Ejemplo n.º 10
0
    def median(self):

        return CallableFloat(nanmedian(self._seq))