def transform(self, func: Callable[(..., 'Series')], axis: Axis=0, *args: Any, **kwargs: Any) -> 'DataFrame':
    "\n        Call ``func`` on self producing a Series with transformed values\n        and that has the same length as its input.\n\n        See also `Transform and apply a function\n        <https://koalas.readthedocs.io/en/latest/user_guide/transform_apply.html>`_.\n\n        .. note:: this API executes the function once to infer the type which is\n             potentially expensive, for instance, when the dataset is created after\n             aggregations or sorting.\n\n             To avoid this, specify return type in ``func``, for instance, as below:\n\n             >>> def square(x) -> ps.Series[np.int32]:\n             ...     return x ** 2\n\n             pandas-on-Spark uses return type hint and does not try to infer the type.\n\n        .. note:: the series within ``func`` is actually multiple pandas series as the\n            segments of the whole pandas-on-Spark series; therefore, the length of each series\n            is not guaranteed. As an example, an aggregation against each series\n            does work as a global aggregation but an aggregation of each segment. See\n            below:\n\n            >>> def func(x) -> ps.Series[np.int32]:\n            ...     return x + sum(x)\n\n        Parameters\n        ----------\n        func : function\n            Function to use for transforming the data. It must work when pandas Series\n            is passed.\n        axis : int, default 0 or 'index'\n            Can only be set to 0 at the moment.\n        *args\n            Positional arguments to pass to func.\n        **kwargs\n            Keyword arguments to pass to func.\n\n        Returns\n        -------\n        DataFrame\n            A DataFrame that must have the same length as self.\n\n        Raises\n        ------\n        Exception : If the returned DataFrame has a different length than self.\n\n        See Also\n        --------\n        DataFrame.aggregate : Only perform aggregating type operations.\n        DataFrame.apply : Invoke function on DataFrame.\n        Series.transform : The equivalent function for Series.\n\n        Examples\n        --------\n        >>> df = ps.DataFrame({'A': range(3), 'B': range(1, 4)}, columns=['A', 'B'])\n        >>> df\n           A  B\n        0  0  1\n        1  1  2\n        2  2  3\n\n        >>> def square(x) -> ps.Series[np.int32]:\n        ...     return x ** 2\n        >>> df.transform(square)\n           A  B\n        0  0  1\n        1  1  4\n        2  4  9\n\n        You can omit the type hint and let pandas-on-Spark infer its type.\n\n        >>> df.transform(lambda x: x ** 2)\n           A  B\n        0  0  1\n        1  1  4\n        2  4  9\n\n        For multi-index columns:\n\n        >>> df.columns = [('X', 'A'), ('X', 'B')]\n        >>> df.transform(square)  # doctest: +NORMALIZE_WHITESPACE\n           X\n           A  B\n        0  0  1\n        1  1  4\n        2  4  9\n\n        >>> (df * -1).transform(abs)  # doctest: +NORMALIZE_WHITESPACE\n           X\n           A  B\n        0  0  1\n        1  1  2\n        2  2  3\n\n        You can also specify extra arguments.\n\n        >>> def calculation(x, y, z) -> ps.Series[int]:\n        ...     return x ** y + z\n        >>> df.transform(calculation, y=10, z=20)  # doctest: +NORMALIZE_WHITESPACE\n              X\n              A      B\n        0    20     21\n        1    21   1044\n        2  1044  59069\n        "
    if (not isinstance(func, types.FunctionType)):
        assert callable(func), 'the first argument should be a callable function.'
        f = func
        func = (lambda *args, **kwargs: f(*args, **kwargs))
    axis = validate_axis(axis)
    if (axis != 0):
        raise NotImplementedError('axis should be either 0 or "index" currently.')
    spec = inspect.getfullargspec(func)
    return_sig = spec.annotations.get('return', None)
    should_infer_schema = (return_sig is None)
    if should_infer_schema:
        log_advice('If the type hints is not specified for `transform`, it is expensive to infer the data type internally.')
        limit = get_option('compute.shortcut_limit')
        pdf = self.head((limit + 1))._to_internal_pandas()
        transformed = pdf.transform(func, axis, *args, **kwargs)
        psdf: DataFrame = DataFrame(transformed)
        if (len(pdf) <= limit):
            return psdf
        applied = []
        data_fields = []
        for (input_label, output_label) in zip(self._internal.column_labels, psdf._internal.column_labels):
            psser = self._psser_for(input_label)
            field = psdf._internal.field_for(output_label).normalize_spark_type()
            data_fields.append(field)
            return_schema = field.spark_type
            applied.append(psser.pandas_on_spark._transform_batch(func=(lambda c: func(c, *args, **kwargs)), return_type=SeriesType(field.dtype, return_schema)))
        internal = self._internal.with_new_columns(applied, data_fields=data_fields)
        return DataFrame(internal)
    else:
        return self._apply_series_op((lambda psser: psser.pandas_on_spark.transform_batch(func, *args, **kwargs)))
Call ``func`` on self producing a Series with transformed values
and that has the same length as its input.

See also `Transform and apply a function
<https://koalas.readthedocs.io/en/latest/user_guide/transform_apply.html>`_.

.. note:: this API executes the function once to infer the type which is
     potentially expensive, for instance, when the dataset is created after
     aggregations or sorting.

     To avoid this, specify return type in ``func``, for instance, as below:

     >>> def square(x) -> ps.Series[np.int32]:
     ...     return x ** 2

     pandas-on-Spark uses return type hint and does not try to infer the type.

.. note:: the series within ``func`` is actually multiple pandas series as the
    segments of the whole pandas-on-Spark series; therefore, the length of each series
    is not guaranteed. As an example, an aggregation against each series
    does work as a global aggregation but an aggregation of each segment. See
    below:

    >>> def func(x) -> ps.Series[np.int32]:
    ...     return x + sum(x)

Parameters
----------
func : function
    Function to use for transforming the data. It must work when pandas Series
    is passed.
axis : int, default 0 or 'index'
    Can only be set to 0 at the moment.
*args
    Positional arguments to pass to func.
**kwargs
    Keyword arguments to pass to func.

Returns
-------
DataFrame
    A DataFrame that must have the same length as self.

Raises
------
Exception : If the returned DataFrame has a different length than self.

See Also
--------
DataFrame.aggregate : Only perform aggregating type operations.
DataFrame.apply : Invoke function on DataFrame.
Series.transform : The equivalent function for Series.

Examples
--------
>>> df = ps.DataFrame({'A': range(3), 'B': range(1, 4)}, columns=['A', 'B'])
>>> df
   A  B
0  0  1
1  1  2
2  2  3

>>> def square(x) -> ps.Series[np.int32]:
...     return x ** 2
>>> df.transform(square)
   A  B
0  0  1
1  1  4
2  4  9

You can omit the type hint and let pandas-on-Spark infer its type.

>>> df.transform(lambda x: x ** 2)
   A  B
0  0  1
1  1  4
2  4  9

For multi-index columns:

>>> df.columns = [('X', 'A'), ('X', 'B')]
>>> df.transform(square)  # doctest: +NORMALIZE_WHITESPACE
   X
   A  B
0  0  1
1  1  4
2  4  9

>>> (df * -1).transform(abs)  # doctest: +NORMALIZE_WHITESPACE
   X
   A  B
0  0  1
1  1  2
2  2  3

You can also specify extra arguments.

>>> def calculation(x, y, z) -> ps.Series[int]:
...     return x ** y + z
>>> df.transform(calculation, y=10, z=20)  # doctest: +NORMALIZE_WHITESPACE
      X
      A      B
0    20     21
1    21   1044
2  1044  59069
def transform(self, func: Callable[(..., 'Series')], axis: Axis=0, *args: Any, **kwargs: Any) -> 'DataFrame':
    "\n        Call ``func`` on self producing a Series with transformed values\n        and that has the same length as its input.\n\n        See also `Transform and apply a function\n        <https://koalas.readthedocs.io/en/latest/user_guide/transform_apply.html>`_.\n\n        .. note:: this API executes the function once to infer the type which is\n             potentially expensive, for instance, when the dataset is created after\n             aggregations or sorting.\n\n             To avoid this, specify return type in ``func``, for instance, as below:\n\n             >>> def square(x) -> ps.Series[np.int32]:\n             ...     return x ** 2\n\n             pandas-on-Spark uses return type hint and does not try to infer the type.\n\n        .. note:: the series within ``func`` is actually multiple pandas series as the\n            segments of the whole pandas-on-Spark series; therefore, the length of each series\n            is not guaranteed. As an example, an aggregation against each series\n            does work as a global aggregation but an aggregation of each segment. See\n            below:\n\n            >>> def func(x) -> ps.Series[np.int32]:\n            ...     return x + sum(x)\n\n        Parameters\n        ----------\n        func : function\n            Function to use for transforming the data. It must work when pandas Series\n            is passed.\n        axis : int, default 0 or 'index'\n            Can only be set to 0 at the moment.\n        *args\n            Positional arguments to pass to func.\n        **kwargs\n            Keyword arguments to pass to func.\n\n        Returns\n        -------\n        DataFrame\n            A DataFrame that must have the same length as self.\n\n        Raises\n        ------\n        Exception : If the returned DataFrame has a different length than self.\n\n        See Also\n        --------\n        DataFrame.aggregate : Only perform aggregating type operations.\n        DataFrame.apply : Invoke function on DataFrame.\n        Series.transform : The equivalent function for Series.\n\n        Examples\n        --------\n        >>> df = ps.DataFrame({'A': range(3), 'B': range(1, 4)}, columns=['A', 'B'])\n        >>> df\n           A  B\n        0  0  1\n        1  1  2\n        2  2  3\n\n        >>> def square(x) -> ps.Series[np.int32]:\n        ...     return x ** 2\n        >>> df.transform(square)\n           A  B\n        0  0  1\n        1  1  4\n        2  4  9\n\n        You can omit the type hint and let pandas-on-Spark infer its type.\n\n        >>> df.transform(lambda x: x ** 2)\n           A  B\n        0  0  1\n        1  1  4\n        2  4  9\n\n        For multi-index columns:\n\n        >>> df.columns = [('X', 'A'), ('X', 'B')]\n        >>> df.transform(square)  # doctest: +NORMALIZE_WHITESPACE\n           X\n           A  B\n        0  0  1\n        1  1  4\n        2  4  9\n\n        >>> (df * -1).transform(abs)  # doctest: +NORMALIZE_WHITESPACE\n           X\n           A  B\n        0  0  1\n        1  1  2\n        2  2  3\n\n        You can also specify extra arguments.\n\n        >>> def calculation(x, y, z) -> ps.Series[int]:\n        ...     return x ** y + z\n        >>> df.transform(calculation, y=10, z=20)  # doctest: +NORMALIZE_WHITESPACE\n              X\n              A      B\n        0    20     21\n        1    21   1044\n        2  1044  59069\n        "
    if (not isinstance(func, types.FunctionType)):
        assert callable(func), 'the first argument should be a callable function.'
        f = func
        func = (lambda *args, **kwargs: f(*args, **kwargs))
    axis = validate_axis(axis)
    if (axis != 0):
        raise NotImplementedError('axis should be either 0 or "index" currently.')
    spec = inspect.getfullargspec(func)
    return_sig = spec.annotations.get('return', None)
    should_infer_schema = (return_sig is None)
    if should_infer_schema:
        log_advice('If the type hints is not specified for `transform`, it is expensive to infer the data type internally.')
        limit = get_option('compute.shortcut_limit')
        pdf = self.head((limit + 1))._to_internal_pandas()
        transformed = pdf.transform(func, axis, *args, **kwargs)
        psdf: DataFrame = DataFrame(transformed)
        if (len(pdf) <= limit):
            return psdf
        applied = []
        data_fields = []
        for (input_label, output_label) in zip(self._internal.column_labels, psdf._internal.column_labels):
            psser = self._psser_for(input_label)
            field = psdf._internal.field_for(output_label).normalize_spark_type()
            data_fields.append(field)
            return_schema = field.spark_type
            applied.append(psser.pandas_on_spark._transform_batch(func=(lambda c: func(c, *args, **kwargs)), return_type=SeriesType(field.dtype, return_schema)))
        internal = self._internal.with_new_columns(applied, data_fields=data_fields)
        return DataFrame(internal)
    else:
        return self._apply_series_op((lambda psser: psser.pandas_on_spark.transform_batch(func, *args, **kwargs)))