pandas add two string columns

Solutions on MaxInterview for pandas add two string columns by the best coders in the world

showing results for - "pandas add two string columns"
Simón
29 Jun 2020
1# if both columns are strings, you can concatenate them directly
2df["period"] = df["Year"] + df["quarter"]
3
4# If one (or both) of the columns are not string typed, you should convert it 
5# (them) first,
6df["period"] = df["Year"].astype(str) + df["quarter"]