code: def ser_to_scalar_pandas_udf_example(spark: SparkSession) -> None:
      import pandas as pd
  
      from pyspark.sql.functions import pandas_udf
      from pyspark.sql import Window
  
      df = spark.createDataFrame(
          [(1, 1.0), (1, 2.0), (2, 3.0), (2, 5.0), (2, 10.0)],
          ("id", "v"),
      )
  
      # Declare the function and create the UDF
      @pandas_udf("double")  # type: ignore[call-overload]
      def mean_udf(v: pd.Series) -> float:
          return v.mean()
  
      df.select(mean_udf(df["v"])).show()
      # +-----------+
      # |mean_udf(v)|
      # +-----------+
      # |        4.2|
      # +-----------+
  
      df.groupby("id").agg(mean_udf(df["v"])).show()
      # +---+-----------+
      # | id|mean_udf(v)|
      # +---+-----------+
      # |  1|        1.5|
      # |  2|        6.0|
      # +---+-----------+
  
      w = Window.partitionBy("id").rowsBetween(
          Window.unboundedPreceding, Window.unboundedFollowing
      )
      df.withColumn("mean_v", mean_udf(df["v"]).over(w)).show()
  
file_path: spark/examples/src/main/python/sql/arrow.py
imports: import pandas
  from typing import Iterable
  from pyspark.sql import SparkSession
  from pyspark.sql.pandas.utils import require_minimum_pandas_version, require_minimum_pyarrow_version
label_desc: Use image node_id 6 for calling a global function with example usage: ser_to_scalar_pandas_udf_example(spark) and returns: v