pandas.DataFrame.isetitem#

DataFrame.isetitem(loc, value)[source]#

Set the given value in the column with position loc.

This is a positional analogue to __setitem__.

Parameters:
locint or sequence of ints

Index position for the column.

valuescalar or arraylike

Value(s) for the column.

Notes

frame.isetitem(loc, value) is an in-place method as it will modify the DataFrame in place (not returning a new object). In contrast to frame.iloc[:, i] = value which will try to update the existing values in place, frame.isetitem(loc, value) will not update the values of the column itself in place, it will instead insert a new array.

In cases where frame.columns is unique, this is equivalent to frame[frame.columns[i]] = value.