I am new to pandas Data frame. i am getting this error TypeError: can only concatenate str (not "int") to str

Viewed 17

I am getting an error from this code:

TypeError: can only concatenate str (not "int") to str

The code:

import pandas as pd
import numpy as np
df = pd.read_excel("test123.xlsx")
print(df)
subone = df["F1"] + df["I1"]
print(subone)

The Excel File mentioned:

   sl no name  F1  F2  Unnamed: 4  Unnamed: 5  I1  I2
0      1  abc   0  95         NaN         NaN  10  54
1      2  def  10  88         NaN         NaN  22  21
2      3  ghi  52  44         NaN         NaN  33  21
3      4  jkl  65  55         NaN         NaN  54  21
4      5  bgm  **AB**  25         NaN         NaN  65  23
1 Answers

If you want to concat two columns

subone = df["F1"].astype(str) + df["l1"].astype(str)
print(subone)
Related