code: def pandas_describe_categorical_1d(
      config: Settings, series: pd.Series, summary: dict
  ) -> Tuple[Settings, pd.Series, dict]:
      """Describe a categorical series.
  
      Args:
          config: report Settings object
          series: The Series to describe.
          summary: The dict containing the series description so far.
  
      Returns:
          A dict containing calculated series description values.
      """
  
      # Make sure we deal with strings (Issue #100)
      series = series.astype(str)
  
      # Only run if at least 1 non-missing value
      value_counts = summary["value_counts_without_nan"]
      value_counts.index = value_counts.index.astype(str)
  
      summary["imbalance"] = column_imbalance_score(
          value_counts, len(value_counts)
      )
  
      redact = config.vars.cat.redact
      if not redact:
          summary.update({"first_rows": series.head(5)})
  
      chi_squared_threshold = config.vars.num.chi_squared_threshold
      if chi_squared_threshold > 0.0:
          summary["chi_squared"] = chi_square(
              histogram=value_counts.values
          )
  
      if config.vars.cat.length:
          summary.update(length_summary_vc(value_counts))
          summary.update(
              histogram_compute(
                  config,
                  summary["length_histogram"].index.values,
                  len(summary["length_histogram"]),
                  name="histogram_length",
                  weights=summary["length_histogram"].values,
              )
          )
  
      if config.vars.cat.characters:
          summary.update(unicode_summary_vc(value_counts))
  
      if config.vars.cat.words:
          summary.update(
              word_summary_vc(value_counts, config.vars.cat.stop_words)
          )
  
      return config, series, summary
  
file_path: ydata-profiling/src/ydata_profiling/model/pandas/describe_categorical_pandas.py
imports: import contextlib
  import string
  from collections import Counter
  from typing import List, Tuple
  import numpy
  import pandas
  from ydata_profiling.config import Settings
  from ydata_profiling.model.pandas.imbalance_pandas import column_imbalance_score
  from ydata_profiling.model.pandas.utils_pandas import weighted_median
  from ydata_profiling.model.summary_algorithms import chi_square, describe_categorical_1d, histogram_compute, series_handle_nulls, series_hashable
label_desc: Use image node_id 7 for calling a global function with example usage: pandas_describe_categorical_1d(config, series, summary) and returns: config,  series,  summary