Currently I am generating unique uuid in each row using loop like this -
df['uuid'] = df.apply(lambda x: uuid.uuid4(), axis=1)
Is there way to do this without loop?
Remains a loop, but is a little faster than the current way
df['uuid'] = [uuid.uuid4() for x in range(df.shape[0])]
24.4 µs ± 2.31 µs per loop (mean ± std. dev. of 7 runs, 10000 loops each)
Using apply
df['uuid'] = df.apply(lambda x: uuid.uuid4(), axis=1)
1.25 ms ± 39.1 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)