code: def to_datetime(
      arg,
      errors: str = "raise",
      format: Optional[str] = None,
      unit: Optional[str] = None,
      infer_datetime_format: bool = False,
      origin: str = "unix",
  ):
      """
      Convert argument to datetime.
  
      Parameters
      ----------
      arg : integer, float, string, datetime, list, tuple, 1-d array, Series
             or DataFrame/dict-like
  
      errors : {'ignore', 'raise', 'coerce'}, default 'raise'
  
          - If 'raise', then invalid parsing will raise an exception
          - If 'coerce', then invalid parsing will be set as NaT
          - If 'ignore', then invalid parsing will return the input
      format : string, default None
          strftime to parse time, eg "%d/%m/%Y", note that "%f" will parse
          all the way up to nanoseconds.
      unit : string, default None
          unit of the arg (D,s,ms,us,ns) denote the unit, which is an
          integer or float number. This will be based off the origin.
          Example, with unit='ms' and origin='unix' (the default), this
          would calculate the number of milliseconds to the unix epoch start.
      infer_datetime_format : boolean, default False
          If True and no `format` is given, attempt to infer the format of the
          datetime strings, and if it can be inferred, switch to a faster
          method of parsing them. In some cases this can increase the parsing
          speed by ~5-10x.
      origin : scalar, default 'unix'
          Define the reference date. The numeric values would be parsed as number
          of units (defined by `unit`) since this reference date.
  
          - If 'unix' (or POSIX) time; origin is set to 1970-01-01.
          - If 'julian', unit must be 'D', and origin is set to beginning of
            Julian Calendar. Julian day number 0 is assigned to the day starting
            at noon on January 1, 4713 BC.
          - If Timestamp convertible, origin is set to Timestamp identified by
            origin.
  
      Returns
      -------
      ret : datetime if parsing succeeded.
          Return type depends on input:
  
          - list-like: DatetimeIndex
          - Series: Series of datetime64 dtype
          - scalar: Timestamp
  
          In case when it is not possible to return designated types (e.g. when
          any element of input is before Timestamp.min or after Timestamp.max)
          return will have datetime.datetime type (or corresponding
          array/Series).
  
      Examples
      --------
      Assembling a datetime from multiple columns of a DataFrame. The keys can be
      common abbreviations like ['year', 'month', 'day', 'minute', 'second',
      'ms', 'us', 'ns']) or plurals of the same
  
      >>> df = ps.DataFrame({'year': [2015, 2016],
      ...                    'month': [2, 3],
      ...                    'day': [4, 5]})
      >>> ps.to_datetime(df)
      0   2015-02-04
      1   2016-03-05
      dtype: datetime64[ns]
  
      If a date does not meet the `timestamp limitations
      <http://pandas.pydata.org/pandas-docs/stable/timeseries.html
      #timeseries-timestamp-limits>`_, passing errors='ignore'
      will return the original input instead of raising any exception.
  
      Passing errors='coerce' will force an out-of-bounds date to NaT,
      in addition to forcing non-dates (or non-parseable dates) to NaT.
  
      >>> ps.to_datetime('13000101', format='%Y%m%d', errors='ignore')  # doctest: +SKIP
      datetime.datetime(1300, 1, 1, 0, 0)
      >>> ps.to_datetime('13000101', format='%Y%m%d', errors='coerce')
      NaT
  
      Passing infer_datetime_format=True can often-times speedup a parsing
      if its not an ISO8601 format exactly, but in a regular format.
  
      >>> s = ps.Series(['3/11/2000', '3/12/2000', '3/13/2000'] * 1000)
      >>> s.head()
      0    3/11/2000
      1    3/12/2000
      2    3/13/2000
      3    3/11/2000
      4    3/12/2000
      dtype: object
  
      >>> import timeit
      >>> timeit.timeit(
      ...    lambda: repr(ps.to_datetime(s, infer_datetime_format=True)),
      ...    number = 1)  # doctest: +SKIP
      0.35832712500000063
  
      >>> timeit.timeit(
      ...    lambda: repr(ps.to_datetime(s, infer_datetime_format=False)),
      ...    number = 1)  # doctest: +SKIP
      0.8895321660000004
  
      Using a unix epoch time
  
      >>> ps.to_datetime(1490195805, unit='s')
      Timestamp('2017-03-22 15:16:45')
      >>> ps.to_datetime(1490195805433502912, unit='ns')
      Timestamp('2017-03-22 15:16:45.433502912')
  
      Using a non-unix epoch origin
  
      >>> ps.to_datetime([1, 2, 3], unit='D', origin=pd.Timestamp('1960-01-01'))
      DatetimeIndex(['1960-01-02', '1960-01-03', '1960-01-04'], dtype='datetime64[ns]', freq=None)
      """
  
      # mappings for assembling units
      # From pandas: pandas.core.tools.datetimes
      _unit_map = {
          "year": "year",
          "years": "year",
          "month": "month",
          "months": "month",
          "day": "day",
          "days": "day",
          "hour": "h",
          "hours": "h",
          "minute": "m",
          "minutes": "m",
          "second": "s",
          "seconds": "s",
          "ms": "ms",
          "millisecond": "ms",
          "milliseconds": "ms",
          "us": "us",
          "microsecond": "us",
          "microseconds": "us",
      }
  
      def pandas_to_datetime(
          pser_or_pdf: Union[pd.DataFrame, pd.Series],
          cols: Optional[List[str]] = None,
      ) -> Series[np.datetime64]:
          if isinstance(pser_or_pdf, pd.DataFrame):
              pser_or_pdf = pser_or_pdf[cols]
          return pd.to_datetime(
              pser_or_pdf,
              errors=errors,
              format=format,
              unit=unit,
              infer_datetime_format=infer_datetime_format,
              origin=origin,
          )
  
      if isinstance(arg, Series):
          return arg.pandas_on_spark.transform_batch(pandas_to_datetime)
      if isinstance(arg, DataFrame):
          unit = {
              k: _unit_map[k.lower()]
              for k in arg.keys()
              if k.lower() in _unit_map
          }
          unit_rev = {v: k for k, v in unit.items()}
          list_cols = [
              unit_rev["year"],
              unit_rev["month"],
              unit_rev["day"],
          ]
          for u in ["h", "m", "s", "ms", "us"]:
              value = unit_rev.get(u)
              if value is not None and value in arg:
                  list_cols.append(value)
  
          psdf = arg[list_cols]
          return psdf.pandas_on_spark.transform_batch(
              pandas_to_datetime, list_cols
          )
      return pd.to_datetime(
          arg,
          errors=errors,
          format=format,
          unit=unit,
          infer_datetime_format=infer_datetime_format,
          origin=origin,
      )
  
imports: from typing import Any, Callable, Dict, List, Optional, Set, Sized, Tuple, Type, Union, cast, no_type_check
  from collections.abc import Iterable
  from datetime import tzinfo
  from functools import reduce
  from io import BytesIO
  import json
  import warnings
  import numpy
  import pandas
  from pandas.api.types import is_datetime64_dtype, is_list_like
  from pandas.tseries.offsets import DateOffset
  import pyarrow
  import pyarrow.parquet
  from pyspark.sql import functions, Column
  from pyspark.sql.functions import pandas_udf
  from pyspark.sql.types import ByteType, ShortType, IntegerType, LongType, FloatType, DoubleType, BooleanType, TimestampType, TimestampNTZType, DecimalType, StringType, DateType, StructType, DataType
  from pyspark.sql.dataframe import DataFrame
  from pyspark import pandas
  from pyspark.pandas._typing import Axis, Dtype, Label, Name
  from pyspark.pandas.base import IndexOpsMixin
  from pyspark.pandas.utils import align_diff_frames, default_session, is_name_like_tuple, is_name_like_value, name_like_string, same_anchor, scol_for, validate_axis, log_advice
  from pyspark.pandas.frame import DataFrame, _reduce_spark_multi
  from pyspark.pandas.internal import InternalFrame, DEFAULT_SERIES_NAME, HIDDEN_COLUMNS, SPARK_INDEX_NAME_FORMAT
  from pyspark.pandas.series import Series, first_series
  from pyspark.pandas.spark.utils import as_nullable_spark_type, force_decimal_precision_scale
  from pyspark.pandas.indexes import Index, DatetimeIndex, TimedeltaIndex
  from pyspark.pandas.indexes.multi import MultiIndex
  from pyspark.sql.utils import get_column_class
label_desc: Use image node_id 15 for calling a global function with example usage: to_datetime(arg, errors, format, unit, infer_datetime_format, origin) and returns: pd, pd, arg, psdf