Combine two columns of text in pandas dataframe

后端 未结 18 1136
-上瘾入骨i
-上瘾入骨i 2020-11-22 01:32

I have a 20 x 4000 dataframe in Python using pandas. Two of these columns are named Year and quarter. I\'d like to create a variable called p

18条回答
  •  情歌与酒
    2020-11-22 02:06

    generalising to multiple columns, why not:

    columns = ['whatever', 'columns', 'you', 'choose']
    df['period'] = df[columns].astype(str).sum(axis=1)
    

提交回复
热议问题