code: def pandas_to_pydf(
      data: pd.DataFrame,
      schema: SchemaDefinition | None = None,
      *,
      schema_overrides: SchemaDict | None = None,
      rechunk: bool = True,
      nan_to_null: bool = True,
      include_index: bool = False,
  ) -> PyDataFrame:
      """Construct a PyDataFrame from a pandas DataFrame."""
      arrow_dict = {}
      length = data.shape[0]
  
      if include_index and not pandas_has_default_index(data):
          for idxcol in data.index.names:
              arrow_dict[str(idxcol)] = _pandas_series_to_arrow(
                  data.index.get_level_values(idxcol),
                  nan_to_null=nan_to_null,
                  length=length,
              )
  
      for col in data.columns:
          arrow_dict[str(col)] = _pandas_series_to_arrow(
              data[col], nan_to_null=nan_to_null, length=length
          )
  
      arrow_table = pa.table(arrow_dict)
      return arrow_to_pydf(
          arrow_table,
          schema=schema,
          schema_overrides=schema_overrides,
          rechunk=rechunk,
      )
  
imports: from __future__ import annotations
  import contextlib
  import warnings
  from datetime import date, datetime, time, timedelta
  from decimal import Decimal
  from functools import lru_cache, singledispatch
  from itertools import islice, zip_longest
  from operator import itemgetter
  from sys import version_info
  from typing import TYPE_CHECKING, Any, Callable, Generator, Iterable, Iterator, Mapping, MutableMapping, Sequence, get_type_hints
  import polars._reexport
  from polars import functions
  from polars.datatypes import INTEGER_DTYPES, N_INFER_DEFAULT, TEMPORAL_DTYPES, Boolean, Categorical, Date, Datetime, Duration, Enum, List, Null, Object, String, Struct, Time, UInt32, Unknown, dtype_to_py_type, is_polars_dtype, numpy_char_code_to_dtype, py_type_to_dtype
  from polars.datatypes.constructor import numpy_type_to_constructor, numpy_values_and_dtype, polars_type_to_constructor, py_type_to_constructor
  from polars.dependencies import _NUMPY_AVAILABLE, _check_for_numpy, _check_for_pandas, _check_for_pydantic, dataclasses, pydantic
  from polars.dependencies import numpy
  from polars.dependencies import pandas
  from polars.dependencies import pyarrow
  from polars.exceptions import ComputeError, ShapeError, TimeZoneAwareConstructorWarning
  from polars.utils._wrap import wrap_df, wrap_s
  from polars.utils.meta import get_index_type, threadpool_size
  from polars.utils.various import _is_generator, arrlen, find_stacklevel, parse_version, range_to_series
label_desc: Use image node_id 42 for calling a global function with example usage: pandas_to_pydf(data, schema) and returns: arrow_to_pydf