pandas concat

21

In [1]: s1 = pd.Series([1, 2], index=['A', 'B'], name='s1')

In [2]: s2 = pd.Series([3, 4], index=['A', 'B'], name='s2')

In [3]: pd.concat([s1, s2], axis=1)
Out[3]:
   s1  s2
A   1   3
B   2   4

In [4]: pd.concat([s1, s2], axis=1).reset_index()
Out[4]:
  index  s1  s2
0     A   1   3
1     B   2   4
import pandas as pd
df = pd.concat(list_of_dataframes)
# Stack the DataFrames on top of each other
#survey_sub and survey_sub_last10 are both dataframes
vertical_stack = pd.concat([survey_sub, survey_sub_last10], axis=0)

# Place the DataFrames side by side
horizontal_stack = pd.concat([survey_sub, survey_sub_last10], axis=1)
pd.concat(objs, axis=0, join='outer', join_axes=None, ignore_index=False,
       keys=None, levels=None, names=None, verify_integrity=False)

result = pd.concat([df1, df4], axis=1)
result = pd.concat(frames, keys=['x', 'y', 'z'])
result = pd.concat([df1, df4], axis=1, join='inner')
result = pd.concat([df1, df4], axis=1, join_axes=[df1.index])

Comments

Submit
0 Comments