def insert(self, loc: int, column: Name, value: Union[(Scalar, 'Series', Iterable)], allow_duplicates: bool=False) -> None:
    '\n        Insert column into DataFrame at specified location.\n\n        Raises a ValueError if `column` is already contained in the DataFrame,\n        unless `allow_duplicates` is set to True.\n\n        Parameters\n        ----------\n        loc : int\n            Insertion index. Must verify 0 <= loc <= len(columns).\n        column : str, number, or hashable object\n            Label of the inserted column.\n        value : int, Series, or array-like\n        allow_duplicates : bool, optional\n\n        Examples\n        --------\n        >>> psdf = ps.DataFrame([1, 2, 3])\n        >>> psdf.sort_index()\n           0\n        0  1\n        1  2\n        2  3\n        >>> psdf.insert(0, \'x\', 4)\n        >>> psdf.sort_index()\n           x  0\n        0  4  1\n        1  4  2\n        2  4  3\n\n        >>> from pyspark.pandas.config import set_option, reset_option\n        >>> set_option("compute.ops_on_diff_frames", True)\n\n        >>> psdf.insert(1, \'y\', [5, 6, 7])\n        >>> psdf.sort_index()\n           x  y  0\n        0  4  5  1\n        1  4  6  2\n        2  4  7  3\n\n        >>> psdf.insert(2, \'z\', ps.Series([8, 9, 10]))\n        >>> psdf.sort_index()\n           x  y   z  0\n        0  4  5   8  1\n        1  4  6   9  2\n        2  4  7  10  3\n\n        >>> reset_option("compute.ops_on_diff_frames")\n        '
    if (not isinstance(loc, int)):
        raise TypeError('loc must be int')
    assert (0 <= loc <= len(self.columns))
    assert (allow_duplicates is False)
    if (not is_name_like_value(column)):
        raise TypeError('"column" should be a scalar value or tuple that contains scalar values')
    if is_name_like_tuple(column):
        if (self._internal.column_labels_level > 1):
            if (len(column) != len(self.columns.levels)):
                raise ValueError('"column" must have length equal to number of column levels.')
        else:
            raise NotImplementedError('Assigning column name as tuple is only supported for MultiIndex columns for now.')
    if (column in self.columns):
        raise ValueError(('cannot insert %s, already exists' % str(column)))
    psdf = self.copy()
    psdf[column] = value
    columns = psdf.columns[:(- 1)].insert(loc, psdf.columns[(- 1)])
    psdf = psdf[columns]
    self._update_internal_frame(psdf._internal)
Insert column into DataFrame at specified location.

Raises a ValueError if `column` is already contained in the DataFrame,
unless `allow_duplicates` is set to True.

Parameters
----------
loc : int
    Insertion index. Must verify 0 <= loc <= len(columns).
column : str, number, or hashable object
    Label of the inserted column.
value : int, Series, or array-like
allow_duplicates : bool, optional

Examples
--------
>>> psdf = ps.DataFrame([1, 2, 3])
>>> psdf.sort_index()
   0
0  1
1  2
2  3
>>> psdf.insert(0, 'x', 4)
>>> psdf.sort_index()
   x  0
0  4  1
1  4  2
2  4  3

>>> from pyspark.pandas.config import set_option, reset_option
>>> set_option("compute.ops_on_diff_frames", True)

>>> psdf.insert(1, 'y', [5, 6, 7])
>>> psdf.sort_index()
   x  y  0
0  4  5  1
1  4  6  2
2  4  7  3

>>> psdf.insert(2, 'z', ps.Series([8, 9, 10]))
>>> psdf.sort_index()
   x  y   z  0
0  4  5   8  1
1  4  6   9  2
2  4  7  10  3

>>> reset_option("compute.ops_on_diff_frames")
def insert(self, loc: int, column: Name, value: Union[(Scalar, 'Series', Iterable)], allow_duplicates: bool=False) -> None:
    '\n        Insert column into DataFrame at specified location.\n\n        Raises a ValueError if `column` is already contained in the DataFrame,\n        unless `allow_duplicates` is set to True.\n\n        Parameters\n        ----------\n        loc : int\n            Insertion index. Must verify 0 <= loc <= len(columns).\n        column : str, number, or hashable object\n            Label of the inserted column.\n        value : int, Series, or array-like\n        allow_duplicates : bool, optional\n\n        Examples\n        --------\n        >>> psdf = ps.DataFrame([1, 2, 3])\n        >>> psdf.sort_index()\n           0\n        0  1\n        1  2\n        2  3\n        >>> psdf.insert(0, \'x\', 4)\n        >>> psdf.sort_index()\n           x  0\n        0  4  1\n        1  4  2\n        2  4  3\n\n        >>> from pyspark.pandas.config import set_option, reset_option\n        >>> set_option("compute.ops_on_diff_frames", True)\n\n        >>> psdf.insert(1, \'y\', [5, 6, 7])\n        >>> psdf.sort_index()\n           x  y  0\n        0  4  5  1\n        1  4  6  2\n        2  4  7  3\n\n        >>> psdf.insert(2, \'z\', ps.Series([8, 9, 10]))\n        >>> psdf.sort_index()\n           x  y   z  0\n        0  4  5   8  1\n        1  4  6   9  2\n        2  4  7  10  3\n\n        >>> reset_option("compute.ops_on_diff_frames")\n        '
    if (not isinstance(loc, int)):
        raise TypeError('loc must be int')
    assert (0 <= loc <= len(self.columns))
    assert (allow_duplicates is False)
    if (not is_name_like_value(column)):
        raise TypeError('"column" should be a scalar value or tuple that contains scalar values')
    if is_name_like_tuple(column):
        if (self._internal.column_labels_level > 1):
            if (len(column) != len(self.columns.levels)):
                raise ValueError('"column" must have length equal to number of column levels.')
        else:
            raise NotImplementedError('Assigning column name as tuple is only supported for MultiIndex columns for now.')
    if (column in self.columns):
        raise ValueError(('cannot insert %s, already exists' % str(column)))
    psdf = self.copy()
    psdf[column] = value
    columns = psdf.columns[:(- 1)].insert(loc, psdf.columns[(- 1)])
    psdf = psdf[columns]
    self._update_internal_frame(psdf._internal)