Merging values of two columns of dataframe with different dtypes

Viewed 439

I have the following pandas dataframe:

import pandas as pd

df = pd.DataFrame({"pos": [1, 2, 3], "chain": ["A", "B", "C"]})

Giving:

  chain  pos
0     A    1
1     B    2
2     C    3

and df.types:

chain    object
pos       int64
dtype: object

I'm looking for a way to merge Series df["chain"] and df["pos"] to have the following:

   chain+pos
0     A1
1     B2
2     C3

and df.dtypes:

chain+pos    object
dtype: object

Is there an easy way to do it?

3 Answers
Related