0
I have a dataframe called df with a column of countries in several languages and another dataframe called ct that I have a column with countries in several languages and another column with the same countries translated pro ingles. I want a datafram df column to have the translation of these countries into English consulted in the dataframe ct as if it were a vlookup. I tried to use the merge, but it is not searching properly.
ct = pd.DataFrame(country, columns=['RAW ORIGIN COUNTRY', 'ORIGIN COUNTRY', 'REGION'])
ct.rename(columns={'RAW ORIGIN COUNTRY':'Raw Origin'}, inplace=True)
df = pd.DataFrame(df, columns=['Raw Origin', 'Origin']
df['Origin'] = pd.merge(df, ct[['Raw Origin', 'ORIGIN COUNTRY']], on='Raw Origin', how='left')
quando eu exporto pro excel fica assim:
[![resultado final][1]][1]
[1]: https://i.stack.imgur.com/ksari.jpg
In order to reproduce the error it would be appropriate to put at least 3 ct and df records.
– Hugo Salvador
The command
pd.merge
returns adataframe
. This makes the column 'Origin' ofdf
be a dataframe and notseries
. That’s what you wanted?– Paulo Marques