Is there any way to map values using column indexes?… here is a solution to the problem.
Is there any way to map values using column indexes?
I’m new to Python and I’m trying to automate some processes with pandas.
df['x'] = df['ID'].map(df5.set_index('x')['y'])
I want it to be generic like this :
df['x'] = df['ID'].map(df5.set_index('x')[iloc[:,[5]]])
Solution
You are close and need to select column 6 without
[]: df[‘x’]
= df['ID'].map(df5.set_index('x').iloc[:,5])