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]]])
Answers:
You are close, need seelct 6th column without []
:
df['x'] = df['ID'].map(df5.set_index('x').iloc[:,5])
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]]])
You are close, need seelct 6th column without []
:
df['x'] = df['ID'].map(df5.set_index('x').iloc[:,5])