I have a dataframe:
df:
ID Date A B C 1 201901 4 5 2 1 201902 3 4 2
I have another table: df1:
Columns B C
While keeping the ID, and Date column.. and I trying to use the columns given in the table as well.
Currently I am using,
df1 = list(df1['Columns'] df1 = ''.join(df1) df = df[['ID','Date',df1]] print(df)
This method isn't working for me.
While I can manually insert B and C.. i need a generalized code that can work with any given table.
Expected output:
ID Date B C 1 201901 5 2 1 201902 4 2
https://stackoverflow.com/questions/67378179/extracting-column-name-from-table May 04, 2021 at 10:51AM
没有评论:
发表评论