我不确定用文字来描述这一点的最佳方式是什么,所以一张图片胜过一千个单词(在这种情况下,一个例子胜过一千个单词:) 我把这个表作为Pandas Dataframe放在了Python上
id | Math | Physics | Morning Class | Night Class |
---|---|---|---|---|
1 | math100 | phys300 | [Math] | [Physics] |
2 | math500 | phys250A | [Physics] | [Math] |
我try 使用"Morning Class"和"Night Class"字段中的值来查看要查看的列并从中提取数据,并在此基础上将"Morning Class"和"Night Class"列值替换为来自"Math"和"物理"字段的映射值.这是最终的表格应该是什么样子
id | Math | Physics | Morning Class | Night Class |
---|---|---|---|---|
1 | math100 | phys300 | math100 | phys300 |
2 | math500 | phys250A | phys250A | math500 |
我想使用Python来实现这一点,我能够在SQL上做到这一点,我觉得这是一个简单的Python问题,但我似乎就是无法用Python解决它,当我试图在线查找时,我找不到任何描述和回答我问题的帖子,如果已经有的话,请随时向我推荐它.谢谢!