大熊猫将文本追加到行中

时间:2020-05-25 11:38:26

标签: python pandas

我只有一列,我试图在行值中添加“,”,但总是

遇到错误,“需要一个整数”

df = df['Cntr_Number'] + ','

print(df['Cntr_Number'].astype(str))

2 个答案:

答案 0 :(得分:1)

尝试一下:

df.loc[:,'Cntr_Number'] = df.Cntr_Number.apply(lambda x: str(x)+',')

答案 1 :(得分:1)

您应该将列强制为str类型:

df['Cntr_Number'] = df['Cntr_Number'].as_type('str') + ','