Combine two columns of text in pandas dataframe

后端 未结 18 1152
-上瘾入骨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 01:59

    my take....

    listofcols = ['col1','col2','col3']
    df['combined_cols'] = ''
    
    for column in listofcols:
        df['combined_cols'] = df['combined_cols'] + ' ' + df[column]
    '''
    

提交回复
热议问题