code: def to_parquet(
      df: DataFrame,
      path: FilePath | WriteBuffer[bytes] | None = None,
      engine: str = "auto",
      compression: str | None = "snappy",
      index: bool | None = None,
      storage_options: StorageOptions | None = None,
      partition_cols: list[str] | None = None,
      filesystem: Any = None,
      **kwargs,
  ) -> bytes | None:
      """
      Write a DataFrame to the parquet format.
  
      Parameters
      ----------
      df : DataFrame
      path : str, path object, file-like object, or None, default None
          String, path object (implementing ``os.PathLike[str]``), or file-like
          object implementing a binary ``write()`` function. If None, the result is
          returned as bytes. If a string, it will be used as Root Directory path
          when writing a partitioned dataset. The engine fastparquet does not
          accept file-like objects.
      engine : {{'auto', 'pyarrow', 'fastparquet'}}, default 'auto'
          Parquet library to use. If 'auto', then the option
          ``io.parquet.engine`` is used. The default ``io.parquet.engine``
          behavior is to try 'pyarrow', falling back to 'fastparquet' if
          'pyarrow' is unavailable.
  
          When using the ``'pyarrow'`` engine and no storage options are provided
          and a filesystem is implemented by both ``pyarrow.fs`` and ``fsspec``
          (e.g. "s3://"), then the ``pyarrow.fs`` filesystem is attempted first.
          Use the filesystem keyword with an instantiated fsspec filesystem
          if you wish to use its implementation.
      compression : {{'snappy', 'gzip', 'brotli', 'lz4', 'zstd', None}},
          default 'snappy'. Name of the compression to use. Use ``None``
          for no compression.
      index : bool, default None
          If ``True``, include the dataframe's index(es) in the file output. If
          ``False``, they will not be written to the file.
          If ``None``, similar to ``True`` the dataframe's index(es)
          will be saved. However, instead of being saved as values,
          the RangeIndex will be stored as a range in the metadata so it
          doesn't require much space and is faster. Other indexes will
          be included as columns in the file output.
      partition_cols : str or list, optional, default None
          Column names by which to partition the dataset.
          Columns are partitioned in the order they are given.
          Must be None if path is not a string.
      {storage_options}
  
      filesystem : fsspec or pyarrow filesystem, default None
          Filesystem object to use when reading the parquet file. Only implemented
          for ``engine="pyarrow"``.
  
          .. versionadded:: 2.1.0
  
      kwargs
          Additional keyword arguments passed to the engine
  
      Returns
      -------
      bytes if no path argument is provided else None
      """
      if isinstance(partition_cols, str):
          partition_cols = [partition_cols]
      impl = get_engine(engine)
  
      path_or_buf: FilePath | WriteBuffer[bytes] = (
          io.BytesIO() if path is None else path
      )
  
      impl.write(
          df,
          path_or_buf,
          compression=compression,
          index=index,
          partition_cols=partition_cols,
          storage_options=storage_options,
          filesystem=filesystem,
          **kwargs,
      )
  
      if path is None:
          assert isinstance(path_or_buf, io.BytesIO)
          return path_or_buf.getvalue()
      else:
          return None
  
imports: from __future__ import annotations
  import io
  import json
  import os
  from typing import TYPE_CHECKING, Any, Literal
  import warnings
  from warnings import catch_warnings
  from pandas._config import using_pyarrow_string_dtype
  from pandas._config.config import _get_option
  from pandas._libs import lib
  from pandas.compat._optional import import_optional_dependency
  from pandas.errors import AbstractMethodError
  from pandas.util._decorators import doc
  from pandas.util._exceptions import find_stack_level
  from pandas.util._validators import check_dtype_backend
  import pandas
  from pandas import DataFrame, get_option
  from pandas.core.shared_docs import _shared_docs
  from pandas.io._util import arrow_string_types_mapper
  from pandas.io.common import IOHandles, get_handle, is_fsspec_url, is_url, stringify_path
label_desc: Use image node_id 3 for calling a global function with example usage: to_parquet(df, path, engine, compression, index, storage_options, partition_cols, filesystem) and returns: path_or_buf, None