def _extract_metrics_for_single_field(
        self,
        records: List[Union[FeedbackRecord, RemoteFeedbackRecord]],
        field: str,
        overwrite: bool = False,
        basic_metrics: Optional[List[str]] = None,
    ) -> Optional[pd.DataFrame]:
        """
        Extract text descriptives metrics for a single field from a list of feedback records
        using the TextDescriptives library.

        Args:
            records (List[Union[FeedbackRecord, RemoteFeedbackRecord]]): A list of FeedbackDataset or RemoteFeedbackDataset records.
            field (str): The name of the field to extract metrics for.
            basic_metrics (Optional[List[str]]): A list of basic metrics to extract. If None, all metrics will be extracted.

        Returns:
            Optional[pd.DataFrame]: A dataframe containing the text descriptives metrics for the field, or None if the field is empty.
        """
        import textdescriptives as td

        def _get_metrics_from_texts(texts: List[str], basic_metrics):
            # If language is english, the default spacy model is used (to avoid warning message)
            field_metrics = td.extract_metrics(text=texts, spacy_model=self.model, metrics=self.metrics)
            # Drop text column
            field_metrics = field_metrics.drop("text", axis=1)
            # If basic metrics is None, use all basic metrics
            if basic_metrics is None and self.metrics is None:
                basic_metrics = self.__basic_metrics
                field_metrics = field_metrics.loc[:, basic_metrics]
            # Convert any None values to NaNs
            field_metrics = field_metrics.fillna(value=np.nan)
            # Select all column names that contain ONLY NaNs
            nan_columns = field_metrics.columns[field_metrics.isnull().all()].tolist()
            if nan_columns:
                warnings.warn(f"The following columns for {field} contain only NaN values: {nan_columns}")
            # Concatenate field name with the metric name
            field_metrics.columns = [f"{field}_{metric}" for metric in field_metrics.columns]
            return field_metrics

        idx_new = []
        idx_present = []
        data_present: List[dict] = []
        field_text = []
        columns: list[str] = _get_metrics_from_texts(["test"], basic_metrics=basic_metrics).columns.tolist()
        for idx, record in enumerate(records):
            if all([field in record.metadata for field in columns]) and not overwrite:
                idx_present.append(idx)
                metadata_relevant: dict[str, Any] = {key: record.metadata[key] for key in columns}
                data_present.append(metadata_relevant)
            elif record.fields.get(field):
                idx_new.append(idx)
                field_text.append(record.fields[field])
            else:
                idx_present.append(idx)
                data_present.append({key: np.nan for key in columns})

        # If the field is empty, skip it
        if not field_text:
            return None

        # Extract metrics for the field
        field_metrics_present = pd.DataFrame(data_present, index=idx_present)
        field_metrics_new = _get_metrics_from_texts(field_text, basic_metrics)
        field_metrics_new.index = idx_new

        # Combine metrics for the field
        field_metrics_combined = pd.concat([field_metrics_present, field_metrics_new])
        field_metrics_combined = field_metrics_combined.sort_index()

        return field_metrics_combined

        Extract text descriptives metrics for a single field from a list of feedback records
        using the TextDescriptives library.

        Args:
            records (List[Union[FeedbackRecord, RemoteFeedbackRecord]]): A list of FeedbackDataset or RemoteFeedbackDataset records.
            field (str): The name of the field to extract metrics for.
            basic_metrics (Optional[List[str]]): A list of basic metrics to extract. If None, all metrics will be extracted.

        Returns:
            Optional[pd.DataFrame]: A dataframe containing the text descriptives metrics for the field, or None if the field is empty.
        
argilla-v1/src/argilla_v1/client/feedback/integrations/textdescriptives.py