code: def describe_with_some_columns_renamed():
      def it_renames_columns_based_on_a_map(spark):
          mapping = {"chips": "french_fries", "petrol": "gas"}
  
          def british_to_american(s):
              return mapping[s]
  
          def change_col_name(s):
              return s in mapping
  
          schema = StructType(
              [
                  StructField("chips", StringType(), True),
                  StructField("hi", StringType(), True),
                  StructField("petrol", StringType(), True),
              ]
          )
          data = [("potato", "hola!", "disel")]
          source_df = spark.createDataFrame(data, schema)
          actual_df = quinn.with_some_columns_renamed(
              british_to_american, change_col_name
          )(source_df)
          expected_df = quinn.create_df(
              spark,
              [("potato", "hola!", "disel")],
              [
                  ("french_fries", StringType(), True),
                  ("hi", StringType(), True),
                  ("gas", StringType(), True),
              ],
          )
          chispa.assert_df_equality(actual_df, expected_df)
  
      def it_renames_some_columns_with_dots(spark):
          def dots_to_underscores(s):
              return s.replace(".", "_")
  
          def change_col_name(s):
              return s.startswith("a")
  
          schema = StructType(
              [
                  StructField("a.person", StringType(), True),
                  StructField("a.thing", StringType(), True),
                  StructField("b.person", StringType(), True),
              ]
          )
          data = [("frank", "hot dog", "mia")]
          source_df = spark.createDataFrame(data, schema)
          actual_df = quinn.with_some_columns_renamed(
              dots_to_underscores, change_col_name
          )(source_df)
          expected_df = quinn.create_df(
              spark,
              [("frank", "hot dog", "mia")],
              [
                  ("a_person", StringType(), True),
                  ("a_thing", StringType(), True),
                  ("b.person", StringType(), True),
              ],
          )
          chispa.assert_df_equality(actual_df, expected_df)
  
imports: from __future__ import annotations
  import pytest
  import chispa
  import quinn
  from pyspark.sql import DataFrame
  from pyspark.sql.types import StructType, StructField, StringType, IntegerType, ArrayType, MapType
  from quinn.transformations import flatten_struct, flatten_map, flatten_dataframe
  from tests.conftest import auto_inject_fixtures
label_desc: Use image node_id 2 for calling a global function with example usage: describe_with_some_columns_renamed() and returns: mapping, unknown, s, s