有没有一种有效的方法来连接 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