bigframes.pandas.DataFrame.insert#
- DataFrame.insert(loc: int, column: blocks.Label, value: SingleItemValue, allow_duplicates: bool = False)[source]#
Insert column into DataFrame at specified location.
Examples:
>>> df = bpd.DataFrame({'col1': [1, 2], 'col2': [3, 4]})
Insert a new column named ‘col3’ between ‘col1’ and ‘col2’ with all entries set to 5.
>>> df.insert(1, 'col3', 5) >>> df col1 col3 col2 0 1 5 3 1 2 5 4 [2 rows x 3 columns]
Insert another column named ‘col2’ at the beginning of the DataFrame with values [5, 6]
>>> df.insert(0, 'col2', [5, 6], allow_duplicates=True) >>> df col2 col1 col3 col2 0 5 1 5 3 1 6 2 5 4 [2 rows x 4 columns]
- Parameters:
- Raises:
IndexError – If
columnindex is out of bounds with the total count of columns.ValueError – If
columnis already contained in the DataFrame, unlessallow_duplicatesis set to True.