Skip to content

Integer

Bases: ColumnType

Type for a column that only contains integers.

Parameters:

Name Type Description Default
is_nullable bool

Whether the type also allows null values.

False
Source code in src/safeds/data/tabular/typing/_column_type.py
@dataclass
class Integer(ColumnType):
    """
    Type for a column that only contains integers.

    Parameters
    ----------
    is_nullable : bool
        Whether the type also allows null values.
    """

    _is_nullable: bool

    def __init__(self, is_nullable: bool = False) -> None:
        self._is_nullable = is_nullable

    def __repr__(self) -> str:
        result = "Integer"
        if self._is_nullable:
            result += "?"
        return result

    def is_nullable(self) -> bool:
        """
        Return whether the given column type is nullable.

        Returns
        -------
        is_nullable : bool
            True if the column is nullable.
        """
        return self._is_nullable

    def is_numeric(self) -> bool:
        """
        Return whether the given column type is numeric.

        Returns
        -------
        is_numeric : bool
            True if the column is numeric.
        """
        return True

__init__(is_nullable=False)

Source code in src/safeds/data/tabular/typing/_column_type.py
def __init__(self, is_nullable: bool = False) -> None:
    self._is_nullable = is_nullable

__repr__()

Source code in src/safeds/data/tabular/typing/_column_type.py
def __repr__(self) -> str:
    result = "Integer"
    if self._is_nullable:
        result += "?"
    return result

is_nullable()

Return whether the given column type is nullable.

Returns:

Name Type Description
is_nullable bool

True if the column is nullable.

Source code in src/safeds/data/tabular/typing/_column_type.py
def is_nullable(self) -> bool:
    """
    Return whether the given column type is nullable.

    Returns
    -------
    is_nullable : bool
        True if the column is nullable.
    """
    return self._is_nullable

is_numeric()

Return whether the given column type is numeric.

Returns:

Name Type Description
is_numeric bool

True if the column is numeric.

Source code in src/safeds/data/tabular/typing/_column_type.py
def is_numeric(self) -> bool:
    """
    Return whether the given column type is numeric.

    Returns
    -------
    is_numeric : bool
        True if the column is numeric.
    """
    return True