I want to use apply(applymap) and lambda functions to get the column name for every element in dfx (a dataframe). The lambda function is used for mapping another dataframe into dfx, and it will be rewritten afterwards.
dfx
A B C
2011-01-10 123 12 123
2011-01-10 12 32 312
2011-01-11 44 1 30.99
pseudocode
output = dfx.apply(lambda r:r.column)
I don't know how to write this part "r:r.column"
intended output
A B C
2011-01-10 A B C
2011-01-10 A B C
2011-01-11 A B C
Any help is more than welcome! Thanks a lot!!
You can assign via pd.DataFrame.iloc:
df.iloc[:] = df.columns
print(df)
A B C
2011-01-10 A B C
2011-01-10 A B C
2011-01-11 A B C
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With