从python数据框中提取一列,并将每一行转换为14位字符串系列

问题描述

我有一个数据帧,如图中的图像,名称为df

enter image description here

我希望从数据帧中单独提取“ GTIN”列,并将每个行号转换为14位数字。最终答案应是一个序列,每列14位数字均来自GTIN

# extracting non duplicates gtin and cinverting to a new data frame
gtin=df.drop_duplicates(subset=[2])
gtin=gtin.rename(columns={2:'GTIN'})
gtin=gtin['GTIN']
type(gtin['GTIN'])

#checking if gtin is less than 14 digits,if less add zeros at beginning to search in sql query
for number in gtin:
     gtin[0].str.zfill(14)

我尝试了上述方法,但是答案仍然不变,即无法将12位数字转换为14位数字。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)