pandas.DataFrame.insert

DataFrame.insert(self, loc, column, value, allow_duplicates=False)[source]

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 : string, number, or hashable object

label of the inserted column

value : int, Series, or array-like
allow_duplicates : bool, optional
Scroll To Top