code: def get_anomalies_dataframe(
      anomalies: anomalies_pb2.Anomalies,
  ) -> pd.DataFrame:
      """Returns a DataFrame containing the input anomalies.
  
      Args:
        anomalies: An Anomalies protocol buffer.
  
      Returns:
        A DataFrame containing the input anomalies, or an empty DataFrame if there
        are no anomalies.
      """
      if not isinstance(anomalies, anomalies_pb2.Anomalies):
          raise TypeError(
              "anomalies is of type %s, should be an Anomalies proto."
              % type(anomalies).__name__
          )
  
      anomaly_rows = []
      for feature_name, anomaly_info in anomalies.anomaly_info.items():
          if not anomaly_info.short_description:
              anomaly_info_short_description = ("; ").join(
                  [r.short_description for r in anomaly_info.reason]
              )
          else:
              anomaly_info_short_description = (
                  anomaly_info.short_description
              )
          if not anomaly_info.description:
              anomaly_info_description = ("; ").join(
                  [r.description for r in anomaly_info.reason]
              )
          else:
              anomaly_info_description = anomaly_info.description
          anomaly_rows.append(
              [
                  _add_quotes(feature_name),
                  anomaly_info_short_description,
                  anomaly_info_description,
              ]
          )
      if anomalies.HasField("dataset_anomaly_info"):
          if not anomalies.dataset_anomaly_info.short_description:
              dataset_anomaly_info_short_description = ("; ").join(
                  [
                      r.short_description
                      for r in anomalies.dataset_anomaly_info.reason
                  ]
              )
          else:
              dataset_anomaly_info_short_description = (
                  anomalies.dataset_anomaly_info.short_description
              )
          if not anomalies.dataset_anomaly_info.description:
              dataset_anomaly_info_description = ("; ").join(
                  [
                      r.description
                      for r in anomalies.dataset_anomaly_info.reason
                  ]
              )
          else:
              dataset_anomaly_info_description = (
                  anomalies.dataset_anomaly_info.description
              )
          anomaly_rows.append(
              [
                  "[dataset anomaly]",
                  dataset_anomaly_info_short_description,
                  dataset_anomaly_info_description,
              ]
          )
  
      # Construct a DataFrame consisting of the anomalies.
      anomalies_df = pd.DataFrame(
          anomaly_rows,
          columns=[
              "Feature name",
              "Anomaly short description",
              "Anomaly long description",
          ],
      ).set_index("Feature name")
      # Do not truncate columns.
      pd.set_option("display.max_colwidth", None)
      return anomalies_df
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import base64
  import collections
  import sys
  from typing import Dict, Iterable, List, Optional, Text, Tuple, Union
  import pandas
  from tensorflow_data_validation import types
  from tensorflow_data_validation.skew.protos import feature_skew_results_pb2
  from tensorflow_data_validation.utils import stats_util
  from tensorflow_metadata.proto.v0 import anomalies_pb2
  from tensorflow_metadata.proto.v0 import schema_pb2
  from tensorflow_metadata.proto.v0 import statistics_pb2
label_desc: Use image node_id 4 for calling a global function with example usage: get_anomalies_dataframe(anomalies) and returns: anomalies_df