【发布时间】:2021-06-09 11:38:22
【问题描述】:
有没有一种有效的方法来连接DataFrame多行的字符串,这样结果是单行,每列的值是同一列的每个值的连接所有给定的行数?
示例
如前所述合并前四行。
>>> df = pd.DataFrame([["this", "this"], ["is", "is"], ["a", "a"], ["test", "test"], ["ignore", "ignore"]])
>>> df
0 1
0 this this
1 is is
2 a a
3 test test
4 ignore ignore
两个都接受的结果:
0 1
0 this is a test this is a test
0
1 this is a test
2 this is a test
【问题讨论】:
标签: pandas dataframe concatenation series pd