code: def from_dataframe(
      df: SupportsInterchange, *, allow_copy: bool = True
  ) -> DataFrame:
      """
      Build a Polars DataFrame from any dataframe supporting the interchange protocol.
  
      Parameters
      ----------
      df
          Object supporting the dataframe interchange protocol, i.e. must have implemented
          the `__dataframe__` method.
      allow_copy
          Allow memory to be copied to perform the conversion. If set to False, causes
          conversions that are not zero-copy to fail.
      """
      if isinstance(df, pl.DataFrame):
          return df
      elif isinstance(df, PolarsDataFrame):
          return df._df
  
      if not hasattr(df, "__dataframe__"):
          raise TypeError(
              f"`df` of type {type(df).__name__!r} does not support the dataframe interchange protocol"
          )
  
      pa_table = _df_to_pyarrow_table(df, allow_copy=allow_copy)
      return from_arrow(pa_table, rechunk=allow_copy)
  
file_path: polars/py-polars/polars/interchange/from_dataframe.py
imports: from __future__ import annotations
  from typing import TYPE_CHECKING, Any
  import polars._reexport
  from polars.convert import from_arrow
  from polars.dependencies import _PYARROW_AVAILABLE
  from polars.dependencies import pyarrow
  from polars.interchange.dataframe import PolarsDataFrame
  from polars.utils.various import parse_version
label_desc: Use image node_id 1 for calling a global function with example usage: from_dataframe(df) and returns: from_arrow, df, df