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

Question:

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]]])
Asked By: Ibrahim Bin Umair

||

Answers:

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

df['x'] = df['ID'].map(df5.set_index('x').iloc[:,5])
Answered By: jezrael
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.