pandas.DataFrame.insert

DataFrame.insert(self, loc, column, value, allow_duplicates=False) → None[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
locint

Insertion index. Must verify 0 <= loc <= len(columns).

columnstr, number, or hashable object

Label of the inserted column.

valueint, Series, or array-like
allow_duplicatesbool, optional