How to combine multiple rows of strings into one using pandas?

前端 未结 4 1490
情话喂你
情话喂你 2021-02-01 19:12

I have a DataFrame with multiple rows. Is there any way in which they can be combined to form one string?

For example:

     words
0    I, will, hereby
1         


        
4条回答
  •  逝去的感伤
    2021-02-01 19:41

    You can use str.cat to join the strings in each row. For a Series or column s, write:

    >>> s.str.cat(sep=', ')
    'I, will, hereby, am, gonna, going, far, to, do, this'
    

提交回复
热议问题