简体   繁体   English

如何将字符串作为新列添加到 Pandas Dataframe?

[英]How to add strings as a new column to Pandas Dataframe?

Let say I have a dataframe, 3 rows, index and 1 column and separate 3 strings.假设我有一个数据框、3 行、索引和 1 列以及单独的 3 个字符串。 How can I add those strings as a 2nd column to existing dataframe?如何将这些字符串作为第二列添加到现有数据框中?

I have: dataframe and 3 strings我有:数据框和 3 个字符串

1 Qwe
2 Asd
3 Zxc

s1 = Poi; s2 = Lkj; s3 = Mnb

I want:我想要:

1 Qwe Poi
2 Asd Lkj
3 Zxc Mnb

Any suggestions?有什么建议?

dataframe['new_col'] = [s1,s2,s3]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM