Skip to content

ExperimentalDataType

Bases: ABC

The type of a column or cell in a table.

Source code in src/safeds/data/tabular/typing/_experimental_data_type.py
class ExperimentalDataType(ABC):
    """The type of a column or cell in a table."""

    # ------------------------------------------------------------------------------------------------------------------
    # Dunder methods
    # ------------------------------------------------------------------------------------------------------------------

    @abstractmethod
    def __eq__(self, other: object) -> bool: ...

    @abstractmethod
    def __hash__(self) -> int: ...

    @abstractmethod
    def __repr__(self) -> str: ...

    @abstractmethod
    def __sizeof__(self) -> int: ...

    @abstractmethod
    def __str__(self) -> str: ...

    # ------------------------------------------------------------------------------------------------------------------
    # Properties
    # ------------------------------------------------------------------------------------------------------------------

    @property
    @abstractmethod
    def is_numeric(self) -> bool:
        """
        Whether the column type is numeric.

        Examples
        --------
        >>> from safeds.data.tabular.containers import ExperimentalTable
        >>> table = ExperimentalTable(
        ...     {
        ...         "A": [1, 2, 3],
        ...         "B": ["a", "b", "c"]
        ...     }
        ... )
        >>> table.get_column_type("A").is_numeric
        True

        >>> table.get_column_type("B").is_numeric
        False
        """

    @property
    @abstractmethod
    def is_temporal(self) -> bool:
        """
        Whether the column type is temporal.

        Examples
        --------
        >>> from datetime import datetime
        >>> from safeds.data.tabular.containers import ExperimentalTable
        >>> table = ExperimentalTable(
        ...     {
        ...         "A": [datetime.now(), datetime.now(), datetime.now()],
        ...         "B": ["a", "b", "c"]
        ...     }
        ... )
        >>> table.get_column_type("A").is_temporal
        True

        >>> table.get_column_type("B").is_temporal
        False
        """

is_numeric: bool abstractmethod property

Whether the column type is numeric.

Examples:

>>> from safeds.data.tabular.containers import ExperimentalTable
>>> table = ExperimentalTable(
...     {
...         "A": [1, 2, 3],
...         "B": ["a", "b", "c"]
...     }
... )
>>> table.get_column_type("A").is_numeric
True
>>> table.get_column_type("B").is_numeric
False

is_temporal: bool abstractmethod property

Whether the column type is temporal.

Examples:

>>> from datetime import datetime
>>> from safeds.data.tabular.containers import ExperimentalTable
>>> table = ExperimentalTable(
...     {
...         "A": [datetime.now(), datetime.now(), datetime.now()],
...         "B": ["a", "b", "c"]
...     }
... )
>>> table.get_column_type("A").is_temporal
True
>>> table.get_column_type("B").is_temporal
False