I am trying to find a quicker way than using a for loop in a for loop to replace the variables in column a in one table with the variables in column b in another table.
for x in range(len(a["a"])):
for y in range(len(b["a"])):
if a["a"][x] == b["a"][y]:
a["a"] = out['a'].replace([a["a"][x]],b["b"][y]])
This currently works but is super slow, is there anyway to do the same thing but make it faster?
Sample Data:
a = pd.DataFrame({'a': ['a','b','c','d','e','f','g', 'h', 'i']})
b = pd.DataFrame({'a': ['a','b','c','d','e','f','g'], 'b': ['alpha', 'alpha', 'alpha', 'beta', 'beta', 'charlie' 'charlie']})
Basically I am trying to replace the value in a["a"] with the values in b["b"] if a["a"] == b["a"]