def cases(self, mapping, default=None):
        """Applies a case statement to this expression, which effectively
        computes the following pseudocode::

            for key, value in mapping.items():
                if self == key:
                    return value

            if default is not None:
                return default

        Examples::

            import fiftyone as fo
            import fiftyone.zoo as foz
            from fiftyone import ViewField as F

            dataset = foz.load_zoo_dataset("quickstart")

            # Set `uniqueness` values below 0.75 to None
            view = dataset.set_field(
                "uniqueness",
                (F("uniqueness") > 0.75).if_else(F("uniqueness"), None)
            )

            # Map numeric `uniqueness` values to 1 and null values to 0
            cases_view = view.set_field(
                "uniqueness",
                F("uniqueness").type().cases({"double": 1, "null": 0}),
            )

            print(cases_view.count_values("uniqueness"))

        Args:
            mapping: a dict mapping literals or :class:`ViewExpression` keys to
                literal or :class:`ViewExpression` values
            default (None): an optional literal or :class:`ViewExpression` to
                return if none of the switch branches are taken

        Returns:
            a :class:`ViewExpression`
        """
        mapping = {ViewField() == k: v for k, v in mapping.items()}
        return self.switch(mapping, default=default)
Applies a case statement to this expression, which effectively
        computes the following pseudocode::

            for key, value in mapping.items():
                if self == key:
                    return value

            if default is not None:
                return default

        Examples::

            import fiftyone as fo
            import fiftyone.zoo as foz
            from fiftyone import ViewField as F

            dataset = foz.load_zoo_dataset("quickstart")

            # Set `uniqueness` values below 0.75 to None
            view = dataset.set_field(
                "uniqueness",
                (F("uniqueness") > 0.75).if_else(F("uniqueness"), None)
            )

            # Map numeric `uniqueness` values to 1 and null values to 0
            cases_view = view.set_field(
                "uniqueness",
                F("uniqueness").type().cases({"double": 1, "null": 0}),
            )

            print(cases_view.count_values("uniqueness"))

        Args:
            mapping: a dict mapping literals or :class:`ViewExpression` keys to
                literal or :class:`ViewExpression` values
            default (None): an optional literal or :class:`ViewExpression` to
                return if none of the switch branches are taken

        Returns:
            a :class:`ViewExpression`
        
fiftyone/core/expressions.py