How to add data from one dataframe to another using Pandas transpose?

前端 未结 3 1003
没有蜡笔的小新
没有蜡笔的小新 2021-01-21 03:56

Objective: to fill in one dataframe with another using transpose

df = pd.DataFrame({\'Attributes\': [\'love\', \'family\',\'tech\']})
df.T
         


        
3条回答
  •  暖寄归人
    2021-01-21 04:12

    Use .loc accessor to set the first row of data using a listified df['Attributes'].

    data.loc[0] = df['Attributes'].tolist()
    

    Result:

      Attribute_01 Attribute_02 Attribute_03
    0         love       family         tech
    

提交回复
热议问题