将UUID添加到pandas

问题描述 投票:1回答:1

如何使用UUID有效填充列?

我的猜测是:

df['uuid'] = pd.Series([uuid.uuid1() for i in range(len(df))])

但我想知道是否可以使用某种内置的pandas方法更有效地完成它。

python pandas uuid
1个回答
0
投票

干得好:

df['uuid'] = df.apply(lambda x: uuid.uuid1(), axis=1)
© www.soinside.com 2019 - 2024. All rights reserved.