将多列的值合并为一列在python的pandas中

15 浏览
0 Comments

将多列的值合并为一列在python的pandas中

我有一个类似这样的pandas数据框:

   Column1  Column2  Column3  Column4  Column5
 0    a        1        2        3        4
 1    a        3        4        5
 2    b        6        7        8
 3    c        7        7        

现在我想要做的是获取一个包含Column1和一个新的列ColumnA的新数据框。这个ColumnA应该包含从Column2到行末尾的所有值,如下所示:

  Column1  ColumnA
0   a      1,2,3,4
1   a      3,4,5
2   b      6,7,8
3   c      7,7

我应该如何最好地处理这个问题?

0