def eval(self, expr: str, inplace: bool=False) -> Optional[DataFrameOrSeries]:
    "\n        Evaluate a string describing operations on DataFrame columns.\n\n        Operates on columns only, not specific rows or elements. This allows\n        `eval` to run arbitrary code, which can make you vulnerable to code\n        injection if you pass user input to this function.\n\n        Parameters\n        ----------\n        expr : str\n            The expression string to evaluate.\n        inplace : bool, default False\n            If the expression contains an assignment, whether to perform the\n            operation inplace and mutate the existing DataFrame. Otherwise,\n            a new DataFrame is returned.\n\n        Returns\n        -------\n        The result of the evaluation.\n\n        See Also\n        --------\n        DataFrame.query : Evaluates a boolean expression to query the columns\n            of a frame.\n        DataFrame.assign : Can evaluate an expression or function to create new\n            values for a column.\n        eval : Evaluate a Python expression as a string using various\n            backends.\n\n        Examples\n        --------\n        >>> df = ps.DataFrame({'A': range(1, 6), 'B': range(10, 0, -2)})\n        >>> df\n           A   B\n        0  1  10\n        1  2   8\n        2  3   6\n        3  4   4\n        4  5   2\n        >>> df.eval('A + B')\n        0    11\n        1    10\n        2     9\n        3     8\n        4     7\n        dtype: int64\n\n        Assignment is allowed though by default the original DataFrame is not\n        modified.\n\n        >>> df.eval('C = A + B')\n           A   B   C\n        0  1  10  11\n        1  2   8  10\n        2  3   6   9\n        3  4   4   8\n        4  5   2   7\n        >>> df\n           A   B\n        0  1  10\n        1  2   8\n        2  3   6\n        3  4   4\n        4  5   2\n\n        Use ``inplace=True`` to modify the original DataFrame.\n\n        >>> df.eval('C = A + B', inplace=True)\n        >>> df\n           A   B   C\n        0  1  10  11\n        1  2   8  10\n        2  3   6   9\n        3  4   4   8\n        4  5   2   7\n        "
    from pyspark.pandas.series import first_series
    if isinstance(self.columns, pd.MultiIndex):
        raise TypeError('`eval` is not supported for multi-index columns')
    inplace = validate_bool_kwarg(inplace, 'inplace')
    should_return_series = False
    series_name = None
    should_return_scalar = False

    def eval_func(pdf):
        nonlocal should_return_series
        nonlocal series_name
        nonlocal should_return_scalar
        result_inner = pdf.eval(expr, inplace=inplace)
        if inplace:
            result_inner = pdf
        if isinstance(result_inner, pd.Series):
            should_return_series = True
            series_name = result_inner.name
            result_inner = result_inner.to_frame()
        elif is_scalar(result_inner):
            should_return_scalar = True
            result_inner = pd.Series(result_inner).to_frame()
        return result_inner
    result = self.pandas_on_spark.apply_batch(eval_func)
    if inplace:
        self._update_internal_frame(result._internal, requires_same_anchor=False)
        return None
    elif should_return_series:
        return first_series(result).rename(series_name)
    elif should_return_scalar:
        return first_series(result)[0]
    else:
        return result
Evaluate a string describing operations on DataFrame columns.

Operates on columns only, not specific rows or elements. This allows
`eval` to run arbitrary code, which can make you vulnerable to code
injection if you pass user input to this function.

Parameters
----------
expr : str
    The expression string to evaluate.
inplace : bool, default False
    If the expression contains an assignment, whether to perform the
    operation inplace and mutate the existing DataFrame. Otherwise,
    a new DataFrame is returned.

Returns
-------
The result of the evaluation.

See Also
--------
DataFrame.query : Evaluates a boolean expression to query the columns
    of a frame.
DataFrame.assign : Can evaluate an expression or function to create new
    values for a column.
eval : Evaluate a Python expression as a string using various
    backends.

Examples
--------
>>> df = ps.DataFrame({'A': range(1, 6), 'B': range(10, 0, -2)})
>>> df
   A   B
0  1  10
1  2   8
2  3   6
3  4   4
4  5   2
>>> df.eval('A + B')
0    11
1    10
2     9
3     8
4     7
dtype: int64

Assignment is allowed though by default the original DataFrame is not
modified.

>>> df.eval('C = A + B')
   A   B   C
0  1  10  11
1  2   8  10
2  3   6   9
3  4   4   8
4  5   2   7
>>> df
   A   B
0  1  10
1  2   8
2  3   6
3  4   4
4  5   2

Use ``inplace=True`` to modify the original DataFrame.

>>> df.eval('C = A + B', inplace=True)
>>> df
   A   B   C
0  1  10  11
1  2   8  10
2  3   6   9
3  4   4   8
4  5   2   7
def eval(self, expr: str, inplace: bool=False) -> Optional[DataFrameOrSeries]:
    "\n        Evaluate a string describing operations on DataFrame columns.\n\n        Operates on columns only, not specific rows or elements. This allows\n        `eval` to run arbitrary code, which can make you vulnerable to code\n        injection if you pass user input to this function.\n\n        Parameters\n        ----------\n        expr : str\n            The expression string to evaluate.\n        inplace : bool, default False\n            If the expression contains an assignment, whether to perform the\n            operation inplace and mutate the existing DataFrame. Otherwise,\n            a new DataFrame is returned.\n\n        Returns\n        -------\n        The result of the evaluation.\n\n        See Also\n        --------\n        DataFrame.query : Evaluates a boolean expression to query the columns\n            of a frame.\n        DataFrame.assign : Can evaluate an expression or function to create new\n            values for a column.\n        eval : Evaluate a Python expression as a string using various\n            backends.\n\n        Examples\n        --------\n        >>> df = ps.DataFrame({'A': range(1, 6), 'B': range(10, 0, -2)})\n        >>> df\n           A   B\n        0  1  10\n        1  2   8\n        2  3   6\n        3  4   4\n        4  5   2\n        >>> df.eval('A + B')\n        0    11\n        1    10\n        2     9\n        3     8\n        4     7\n        dtype: int64\n\n        Assignment is allowed though by default the original DataFrame is not\n        modified.\n\n        >>> df.eval('C = A + B')\n           A   B   C\n        0  1  10  11\n        1  2   8  10\n        2  3   6   9\n        3  4   4   8\n        4  5   2   7\n        >>> df\n           A   B\n        0  1  10\n        1  2   8\n        2  3   6\n        3  4   4\n        4  5   2\n\n        Use ``inplace=True`` to modify the original DataFrame.\n\n        >>> df.eval('C = A + B', inplace=True)\n        >>> df\n           A   B   C\n        0  1  10  11\n        1  2   8  10\n        2  3   6   9\n        3  4   4   8\n        4  5   2   7\n        "
    from pyspark.pandas.series import first_series
    if isinstance(self.columns, pd.MultiIndex):
        raise TypeError('`eval` is not supported for multi-index columns')
    inplace = validate_bool_kwarg(inplace, 'inplace')
    should_return_series = False
    series_name = None
    should_return_scalar = False

    def eval_func(pdf):
        nonlocal should_return_series
        nonlocal series_name
        nonlocal should_return_scalar
        result_inner = pdf.eval(expr, inplace=inplace)
        if inplace:
            result_inner = pdf
        if isinstance(result_inner, pd.Series):
            should_return_series = True
            series_name = result_inner.name
            result_inner = result_inner.to_frame()
        elif is_scalar(result_inner):
            should_return_scalar = True
            result_inner = pd.Series(result_inner).to_frame()
        return result_inner
    result = self.pandas_on_spark.apply_batch(eval_func)
    if inplace:
        self._update_internal_frame(result._internal, requires_same_anchor=False)
        return None
    elif should_return_series:
        return first_series(result).rename(series_name)
    elif should_return_scalar:
        return first_series(result)[0]
    else:
        return result