Vedda
Vedda

Reputation: 7435

Join(Combine) two series in pandas

I'd like to join/combine two columns in a data frame.

Data

import pandas as pd
dat = pd.DataFrame({'A' : [1, 2, 3], 'B' : [4, 5, 6]})

Desired Output

14
25
36

Upvotes: 1

Views: 57

Answers (1)

BENY
BENY

Reputation: 323226

Using apply with join

dat.astype(str).apply(''.join,1)
Out[210]: 
0    14
1    25
2    36
dtype: object

Or (PS not always work)

dat.A*10+dat.B
Out[211]: 
0    14
1    25
2    36
dtype: int64

Upvotes: 1

Related Questions