pandas concatenate series code example
Example 1: pandas concat series into dataframe
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
Example 2: dataframe concatenate
# Pandas for Python
df['col1 & col2'] = df['col1']+df['col2']
#Output
#col1 col2 col1 & col2
#A1 A2 A1A2
#B1 B2 B1B2