Answers for "how to combine multiple string columns into on pandas"

2

python merge strings in columns

df["period"] = df["Year"].astype(str) + df["quarter"]
Posted by: Guest on October-19-2020
0

pandas add two string columns

# if both columns are strings, you can concatenate them directly
df["period"] = df["Year"] + df["quarter"]

# If one (or both) of the columns are not string typed, you should convert it 
# (them) first,
df["period"] = df["Year"].astype(str) + df["quarter"]
Posted by: Guest on August-31-2021

Code answers related to "how to combine multiple string columns into on pandas"

Python Answers by Framework

Browse Popular Code Answers by Language