Skip to content

DuplicateStatisticError(statistic, other_statistic=None) Source

Bases: NumdaplotError

Raised when two statistics of a Description would give rows of the same name.

Two statistics have the same name when they have the same class and the same settings, so Quantile(0.25) and Quantile(0.75) are different. Two Share have the same name whatever their rules.

Added in version 0.1.0

Changed in version 0.2.0

Also raised for two different statistics of the same name, such as two Share.

Parameters:

  • statistic (object)

    The statistic given twice, or the first of two statistics of the same name.

  • other_statistic (object | None, default: None)

    The second statistic of the same name. When omitted, statistic itself appears twice.

Attributes:

  • statistic

    The statistic given twice, or the first of two statistics of the same name.

  • other_statistic

    The second statistic of the same name, None when statistic itself appears twice.

Examples:

import numdaplot as ndp

try:
    ndp.Description(functions=[ndp.Sum(), ndp.Sum()])
except ndp.DuplicateStatisticError as error:
    print(error)
# The statistic Sum() appears more than once.
try:
    ndp.Description(functions=[ndp.Share(ndp.Greater(65)), ndp.Share(ndp.Less(18))])
except ndp.DuplicateStatisticError as error:
    print(error)
# The statistics Share(rule=Greater(value=65), missing=<CountedMissing.EXCLUDED: 1>)
# and Share(rule=Less(value=18), missing=<CountedMissing.EXCLUDED: 1>) give rows of the same name.
# Use aggregate with a result_name for each, or one description per statistic.