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,
      partition_cols: list[str] | None = 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.
  
          .. versionchanged:: 1.2.0
  
      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.
      compression : {{'snappy', 'gzip', 'brotli', 'lz4', 'zstd', None}},
          default 'snappy'. Name of the compression to use. Use ``None``
          for no compression. The supported compression methods actually
          depend on which engine is used. For 'pyarrow', 'snappy', 'gzip',
          'brotli', 'lz4', 'zstd' are all supported. For 'fastparquet',
          only 'gzip' and 'snappy' are supported.
      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}
  
          .. versionadded:: 1.2.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,
          **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 os
  from typing import Any, Literal
  import warnings
  from warnings import catch_warnings
  from pandas._libs import lib
  from pandas._typing import DtypeBackend, FilePath, ReadBuffer, StorageOptions, WriteBuffer
  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.util.version import Version
  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) and returns: path_or_buf, None