I'm trying to add a column based on existing column values matching with a dataframe with a different length.
from pandas import DataFrame
a = DataFrame([['a', '1'], ['b', 2], ['c', 3]], columns=['Letters', 'Numbers'])
b = DataFrame([['a', '2001'], ['b', '2002'], ['c', '2003'], ['d', '2004']], columns=['Letters', 'Years'])
How can I add a column to a called Years which has the year where Letters of a and b match.
Desired output:
df = DataFrame([['a', '1', '2001'], ['b', 2, '2002'], ['c', 3, '2003']], columns=['Letters', 'Numbers', 'Years'])