📜  pandas 添加两个字符串列 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:29.978000             🧑  作者: Mango

代码示例1
# 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"]