<Python, pandas> データフレームの結合
まずはデータフレーム。
In [31]: df1 = pd.DataFrame([(1,2),(3,4)]) In [32]: df1 Out[32]: 0 1 0 1 2 1 3 4 In [33]: df2 = pd.DataFrame([(5,6),(7,8)]) In [34]: df2 Out[34]: 0 1 0 5 6 1 7 8
縦に合体。
In [35]: df1.append(df2) Out[35]: 0 1 0 1 2 1 3 4 0 5 6 1 7 8 In [36]: pd.concat([df1, df2], axis=0) Out[36]: 0 1 0 1 2 1 3 4 0 5 6 1 7 8
横に合体。
In [37]: pd.concat([df1, df2], axis=1) Out[37]: 0 1 0 1 0 1 2 5 6 1 3 4 7 8