Objective: to fill in one dataframe with another using transpose
df = pd.DataFrame({\'Attributes\': [\'love\', \'family\',\'tech\']})
df.T
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
I think you just need to change the column name in df1
df.columns=data.columns
df
Out[741]:
Attribute_01 Attribute_02 Attribute_03
Attributes love family tech
Setup
df
Attributes
0 love
1 family
2 tech
Option 1
rename
df.T.rename(dict(enumerate(data.columns)), axis=1)
Attribute_01 Attribute_02 Attribute_03
Attributes love family tech
Option 2
set_index
df.set_index(data.columns).T
Attribute_01 Attribute_02 Attribute_03
Attributes love family tech