def create_summary_field(
        self,
        path,
        field_name=None,
        sidebar_group=None,
        include_counts=False,
        group_by=None,
        read_only=True,
        create_index=True,
    ):
        """Populates a sample-level field that records the unique values or
        numeric ranges that appear in the specified field on each sample in
        the dataset.

        This method is particularly useful for summarizing frame-level fields
        of video datasets, in which case the sample-level field records the
        unique values or numeric ranges that appear in the specified
        frame-level field across all frames of that sample. This summary field
        can then be efficiently queried to retrieve samples that contain
        specific values of interest in at least one frame.

        Examples::

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

            dataset = foz.load_zoo_dataset("quickstart-video")
            dataset.set_field("frames.detections.detections.confidence", F.rand()).save()

            # Generate a summary field for object labels
            dataset.create_summary_field("frames.detections.detections.label")

            # Generate a summary field for [min, max] confidences
            dataset.create_summary_field("frames.detections.detections.confidence")

            # Generate a summary field for object labels and counts
            dataset.create_summary_field(
                "frames.detections.detections.label",
                field_name="frames_detections_label2",
                include_counts=True,
            )

            # Generate a summary field for per-label [min, max] confidences
            dataset.create_summary_field(
                "frames.detections.detections.confidence",
                field_name="frames_detections_confidence2",
                group_by="label",
            )

            print(dataset.list_summary_fields())

        Args:
            path: an input field path
            field_name (None): the sample-level field in which to store the
                summary data. By default, a suitable name is derived from the
                given ``path``
            sidebar_group (None): the name of a
                :ref:`App sidebar group <app-sidebar-groups>` to which to add
                the summary field. By default, all summary fields are added to
                a ``"summaries"`` group. You can pass ``False`` to skip sidebar
                group modification
            include_counts (False): whether to include per-value counts when
                summarizing categorical fields
            group_by (None): an optional attribute to group by when ``path``
                is a numeric field to generate per-attribute ``[min, max]``
                ranges. This may either be an absolute path or an attribute
                name that is interpreted relative to ``path``
            read_only (True): whether to mark the summary field as read-only
            create_index (True): whether to create database index(es) for the
                summary field

        Returns:
            the summary field name
        """
        _field = self.get_field(path)

        is_list_field = isinstance(_field, fof.ListField)
        if is_list_field:
            _field = _field.field

        if isinstance(
            _field,
            (fof.StringField, fof.BooleanField, fof.ObjectIdField),
        ):
            field_type = "categorical"
        elif isinstance(
            _field,
            (fof.FloatField, fof.IntField, fof.DateField, fof.DateTimeField),
        ):
            field_type = "numeric"
        elif is_list_field:
            raise ValueError(
                f"Cannot generate a summary for list field '{path}' with "
                f"element type {type(_field)}"
            )
        elif _field is not None:
            raise ValueError(
                f"Cannot generate a summary for field '{path}' of "
                f"type {type(_field)}"
            )
        else:
            raise ValueError(
                "Cannot generate a summary field for non-existent or "
                f"undeclared field '{path}'"
            )

        if field_name is None:
            field_name = self._get_default_summary_field_name(path)

        index_fields = []
        summary_info = {"path": path, "field_type": field_type}
        if field_type == "categorical":
            summary_info["include_counts"] = include_counts
            if include_counts:
                label_field = field_name + ".label"
                count_field = field_name + ".count"
                index_fields.extend([label_field, count_field])

                self.add_sample_field(
                    field_name,
                    fof.ListField,
                    subfield=fof.EmbeddedDocumentField,
                    embedded_doc_type=foo.DynamicEmbeddedDocument,
                    info={_SUMMARY_FIELD_KEY: summary_info},
                )
                self.add_sample_field(label_field, type(_field))
                self.add_sample_field(count_field, fof.IntField)
            else:
                index_fields.append(field_name)
                self.add_sample_field(
                    field_name,
                    fof.ListField,
                    subfield=type(_field),
                    info={_SUMMARY_FIELD_KEY: summary_info},
                )
        elif field_type == "numeric":
            summary_info["group_by"] = group_by
            if group_by is not None:
                if "." in group_by:
                    value = group_by.rsplit(".", 1)[1]
                    group_path = group_by
                else:
                    value = group_by
                    group_path = path.rsplit(".", 1)[0] + "." + group_by

                _group_field = self.get_field(group_path)

                value_field = field_name + f".{value}"
                min_field = field_name + ".min"
                max_field = field_name + ".max"
                index_fields.extend([value_field, min_field, max_field])

                self.add_sample_field(
                    field_name,
                    fof.ListField,
                    subfield=fof.EmbeddedDocumentField,
                    embedded_doc_type=foo.DynamicEmbeddedDocument,
                    info={_SUMMARY_FIELD_KEY: summary_info},
                )
                self.add_sample_field(value_field, type(_group_field))
                self.add_sample_field(min_field, type(_field))
                self.add_sample_field(max_field, type(_field))
            else:
                min_field = field_name + ".min"
                max_field = field_name + ".max"
                index_fields.extend([min_field, max_field])

                self.add_sample_field(
                    field_name,
                    fof.EmbeddedDocumentField,
                    embedded_doc_type=foo.DynamicEmbeddedDocument,
                    info={_SUMMARY_FIELD_KEY: summary_info},
                )
                self.add_sample_field(min_field, type(_field))
                self.add_sample_field(max_field, type(_field))

        if sidebar_group is not False:
            if sidebar_group is None:
                sidebar_group = "summaries"

            self.app_config._add_path_to_sidebar_group(
                field_name,
                sidebar_group,
                after_group="labels",
                dataset=self,
            )

        if create_index:
            for _field_name in index_fields:
                self.create_index(_field_name)

        field = self.get_field(field_name)
        field.info[_SUMMARY_FIELD_KEY]["last_modified_at"] = field.created_at

        if read_only:
            field.read_only = True

        field.save()

        self._populate_summary_field(field_name, summary_info)

        return field_name
Populates a sample-level field that records the unique values or
        numeric ranges that appear in the specified field on each sample in
        the dataset.

        This method is particularly useful for summarizing frame-level fields
        of video datasets, in which case the sample-level field records the
        unique values or numeric ranges that appear in the specified
        frame-level field across all frames of that sample. This summary field
        can then be efficiently queried to retrieve samples that contain
        specific values of interest in at least one frame.

        Examples::

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

            dataset = foz.load_zoo_dataset("quickstart-video")
            dataset.set_field("frames.detections.detections.confidence", F.rand()).save()

            # Generate a summary field for object labels
            dataset.create_summary_field("frames.detections.detections.label")

            # Generate a summary field for [min, max] confidences
            dataset.create_summary_field("frames.detections.detections.confidence")

            # Generate a summary field for object labels and counts
            dataset.create_summary_field(
                "frames.detections.detections.label",
                field_name="frames_detections_label2",
                include_counts=True,
            )

            # Generate a summary field for per-label [min, max] confidences
            dataset.create_summary_field(
                "frames.detections.detections.confidence",
                field_name="frames_detections_confidence2",
                group_by="label",
            )

            print(dataset.list_summary_fields())

        Args:
            path: an input field path
            field_name (None): the sample-level field in which to store the
                summary data. By default, a suitable name is derived from the
                given ``path``
            sidebar_group (None): the name of a
                :ref:`App sidebar group <app-sidebar-groups>` to which to add
                the summary field. By default, all summary fields are added to
                a ``"summaries"`` group. You can pass ``False`` to skip sidebar
                group modification
            include_counts (False): whether to include per-value counts when
                summarizing categorical fields
            group_by (None): an optional attribute to group by when ``path``
                is a numeric field to generate per-attribute ``[min, max]``
                ranges. This may either be an absolute path or an attribute
                name that is interpreted relative to ``path``
            read_only (True): whether to mark the summary field as read-only
            create_index (True): whether to create database index(es) for the
                summary field

        Returns:
            the summary field name
        
fiftyone/core/dataset.py