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
dataframeplan?– Sidon
@Sidon good morning, my friend
GBrandtmanaged to solve this my problem, in relation to your comment would show yes, the part that interested me was theCodand within that column would show me several ex codes:01, 02, 03...for eachCodinside that column would need another column calledCidadesthat 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 Janeirobasically was that, I hope you have understood this my explanation rsrs, thank you for the interest in wanting to help, vlw even!– Magno