Maduna
0
Q:

how to add the column to the beginning of dataframe

insert_index = 0
insert_colname = 'new column'
insert_values = [1, 2, 3, 4, 5] # this can be a numpy array too
df.insert(loc=insert_index, column=insert_colname, value=insert_values)
4
# Third position would be at index 2, because of zero-indexing.
df.insert(2, 'new-col', data)
1

New to Communities?

Join the community