我是 python 的新手,我试图通过 pandas 自动化一些流程。
df['x'] = df['ID'].map(df5.set_index('x')['y'])
我想让它像这样通用:
df['x'] = df['ID'].map(df5.set_index('x')[iloc[:,[5]]])
最佳答案
你很接近,需要选择没有[]
的第6列:
df['x'] = df['ID'].map(df5.set_index('x').iloc[:,5])
关于python - 有什么方法可以使用列索引映射值吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73416493/