code: def _from_dataframe(df: DataFrameObject, allow_copy=True):
      """
      Build a ``pa.Table`` from the DataFrame interchange object.
  
      Parameters
      ----------
      df : DataFrameObject
          Object supporting the interchange protocol, i.e. `__dataframe__`
          method.
      allow_copy : bool, default: True
          Whether to allow copying the memory to perform the conversion
          (if false then zero-copy approach is requested).
  
      Returns
      -------
      pa.Table
      """
      batches = []
      for chunk in df.get_chunks():
          batch = protocol_df_chunk_to_pyarrow(chunk, allow_copy)
          batches.append(batch)
  
      if not batches:
          batch = protocol_df_chunk_to_pyarrow(df)
          batches.append(batch)
  
      return pa.Table.from_batches(batches)
  
file_path: arrow/python/pyarrow/interchange/from_dataframe.py
imports: from __future__ import annotations
  from typing import Any, Tuple
  from pyarrow.interchange.column import DtypeKind, ColumnBuffers, ColumnNullType
  import pyarrow
  import re
  import pyarrow.compute
  from pyarrow.interchange.column import Dtype
label_desc: Use image node_id 2 for calling a global function with example usage: _from_dataframe(df, allow_copy) and returns: pa