最佳答案
I would like to add a column 'D' to a dataframe like this:
U,L
111,en
112,en
112,es
113,es
113,ja
113,zh
114,es
based on the following Dictionary:
d = {112: 'en', 113: 'es', 114: 'es', 111: 'en'}
so that the resulting dataframe appears as:
U,L,D
111,en,en
112,en,en
112,es,en
113,es,es
113,ja,es
113,zh,es
114,es,es
So far I tried the pd.join()
method but I can't figured out how it works with Dictionaries.