I have a dataframe with over 5M rows. I am concerned with just one column in this dataframe. Let's assume dataframe name to be df
and the column in consideration to be df['id']
. An example of the dataframe is shown below:
df['id'] :
id
0 432000000
1 432000010
2 432000020
The column df['id]
is stored as a string.
I want to add a prefix to all the rows of a particular column in this dataframe. Below is the code I use:
for i in tqdm(range(0,len(df['id']))):
df['id'][i]='ABC-1234-'+df['id'][i]
While the above code works, it shows 15 hours to complete. Is there a more efficient way to perform this task ?