Is there any way to map values using the column index?

Viewed 49

I am new to python I was trying to automate some processes through pandas.

df['x'] = df['ID'].map(df5.set_index('x')['y'])

I want to make it generic like:

    df['x'] = df['ID'].map(df5.set_index('x')[iloc[:,[5]]])
1 Answers

You are close, need seelct 6th column without []:

df['x'] = df['ID'].map(df5.set_index('x').iloc[:,5])
Related