我希望根据大学/学院名称词典,使数据集中的教育数据保持一致。如何对字典运行代码并获得所需的输出?数据包括缩写和俗语名称
有人能在R中提供一个例子吗?我也愿意在python中尝试,R只是我的首选
这是我的字典的一个例子:
*University Name Dictionary
California Institute of Technology
New York University
Massachusetts Institute of Technology
Georgia Institute of Technology
Rutgers University
University of California, Berkley
University of California, Los Angeles
这是我的数据:
*Education
Cal Tech
NYU
MIT
Ga Tech
Georgia Tech
Rutgers
Berkley
UCLA
这就是我想要的:
*Education *New Education
Cal Tech California Institute of Technology
NYU New York University
MIT Massachusetts Institute of Technology
Ga Tech Georgia Institute of Technology
Georgia Tech Georgia Institute of Technology
Rutgers Rutgers University
Berkley University of California, Berkley
UCLA University of California, Los Angeles
抱歉,如果已经有了解决方案,我就是找不到。我将感谢任何帮助
pandas
有函数replace(dictionary)
,其中dictionary
类似于因为
pandas.DataFrame
的灵感来自R
,所以R
可能有类似的东西结果:
如果您使用
regex=True
,那么它也可以替换为更长的字符串结果:
文件:pandas.DataFrame.replace()
相关问题 更多 >
编程相关推荐