コード例 #1
0
ファイル: stdev.py プロジェクト: 01-/agate
class StDev(Aggregation):
    """
    Calculate the sample standard of deviation of a column.

    For the population standard of deviation see :class:`.PopulationStDev`.

    :param column_name:
        The name of a column containing :class:`.Number` data.
    """
    def __init__(self, column_name):
        self._column_name = column_name
        self._variance = Variance(column_name)

    def get_aggregate_data_type(self, table):
        return Number()

    def validate(self, table):
        column = table.columns[self._column_name]

        if not isinstance(column.data_type, Number):
            raise DataTypeError('StDev can only be applied to columns containing Number data.')

        has_nulls = HasNulls(self._column_name).run(table)

        if has_nulls:
            warn_null_calculation(self, column)

    def run(self, table):
        return self._variance.run(table).sqrt()
コード例 #2
0
class StDev(Aggregation):
    """
    Calculate the sample standard of deviation of a column.

    For the population standard of deviation see :class:`.PopulationStDev`.

    :param column_name:
        The name of a column containing :class:`.Number` data.
    """
    def __init__(self, column_name):
        self._column_name = column_name
        self._variance = Variance(column_name)

    def get_aggregate_data_type(self, table):
        return Number()

    def validate(self, table):
        column = table.columns[self._column_name]

        if not isinstance(column.data_type, Number):
            raise DataTypeError('StDev can only be applied to columns containing Number data.')

        has_nulls = HasNulls(self._column_name).run(table)

        if has_nulls:
            warn_null_calculation(self, column)

    def run(self, table):
        variance = self._variance.run(table)
        if variance is not None:
            return variance.sqrt()
コード例 #3
0
ファイル: stdev.py プロジェクト: 01-/agate
 def __init__(self, column_name):
     self._column_name = column_name
     self._variance = Variance(column_name)
コード例 #4
0
 def __init__(self, column_name):
     self._column_name = column_name
     self._variance = Variance(column_name)