class_docstr: Serializer used by Python worker to evaluate Pandas UDFs
class_docstr_tok: ["Serializer","used","by","Python","worker","to","evaluate","Pandas","UDFs"]
docstr: Create an Arrow record batch from the given pandas.Series pandas.DataFrame
  or list of Series or DataFrame, with optional type.
  
  Parameters
  ----------
  series : pandas.Series or pandas.DataFrame or list
      A single series or dataframe, list of series or dataframe,
      or list of (series or dataframe, arrow_type)
  
  Returns
  -------
  pyarrow.RecordBatch
      Arrow RecordBatch
code: def _create_batch(self, series):
      """
      Create an Arrow record batch from the given pandas.Series pandas.DataFrame
      or list of Series or DataFrame, with optional type.
  
      Parameters
      ----------
      series : pandas.Series or pandas.DataFrame or list
          A single series or dataframe, list of series or dataframe,
          or list of (series or dataframe, arrow_type)
  
      Returns
      -------
      pyarrow.RecordBatch
          Arrow RecordBatch
      """
      import pandas as pd
      import pyarrow as pa
  
      # Make input conform to [(series1, type1), (series2, type2), ...]
      if not isinstance(series, (list, tuple)) or (
          len(series) == 2 and isinstance(series[1], pa.DataType)
      ):
          series = [series]
      series = (
          (s, None) if not isinstance(s, (list, tuple)) else s
          for s in series
      )
  
      arrs = []
      for s, t in series:
          if (
              self._struct_in_pandas == "dict"
              and t is not None
              and pa.types.is_struct(t)
          ):
              # A pandas UDF should return pd.DataFrame when the return type is a struct type.
              # If it returns a pd.Series, it should throw an error.
              if not isinstance(s, pd.DataFrame):
                  raise PySparkValueError(
                      "A field of type StructType expects a pandas.DataFrame, "
                      "but got: %s" % str(type(s))
                  )
              arrs.append(self._create_struct_array(s, t))
          else:
              arrs.append(
                  self._create_array(s, t, arrow_cast=self._arrow_cast)
              )
  
      return pa.RecordBatch.from_arrays(
          arrs, ["_%d" % i for i in range(len(arrs))]
      )
  
imports: from pyspark.errors import PySparkRuntimeError, PySparkTypeError, PySparkValueError
  from pyspark.loose_version import LooseVersion
  from pyspark.serializers import Serializer, read_int, write_int, UTF8Deserializer, CPickleSerializer
  from pyspark.sql.pandas.types import from_arrow_type, to_arrow_type, _create_converter_from_pandas, _create_converter_to_pandas
  from pyspark.sql.types import DataType, StringType, StructType, BinaryType, StructField, LongType, IntegerType
label_desc: Use image node_id 4 for calling the ArrowStreamPandasUDFSerializer obj's underlying member method code with example usage: obj._create_batch(series) and returns: pa