0
Good evening, I have an Excel spreadsheet that has a column called Cod
and within that column are the valores: 01, 02, 03
I need to create another column in this table that does the following:
- According to the values of the column "Cod" assign the names of the Cities
Ex:
01 = São Paulo
02 = Belo Horizonte
03 = Rio de Janeiro
In other words, this other column will receive the names of Cidades
in accordance with the Cod
of them, I tried to do so:
data_teste = {'Cidades': ['São Paulo', 'Belo Horizonte', 'Rio de Janeiro']}
resultado = pd.DataFrame(data_teste, index=[01, 02, 03])
plan = pd.read_excel('teste.xlsx', header=3)
for i in plan['Cod'].values:
if i in resultado.loc[i]:
plan['Nomes Cidades] = resultado.values
But I didn’t succeed, someone could help me?
To show a part of the
dataframe
plan?– Sidon
@Sidon good morning, my friend
GBrandt
managed to solve this my problem, in relation to your comment would show yes, the part that interested me was theCod
and within that column would show me several ex codes:01, 02, 03...
for eachCod
inside that column would need another column calledCidades
that would give the name of the correct city according to that Cod, for example theCod 01 = São Paulo | 02 = Belo Horizonte | 03 = Rio de Janeiro
basically was that, I hope you have understood this my explanation rsrs, thank you for the interest in wanting to help, vlw even!– Magno