7
I am using pandas to process a CSV file in the following structure:
nome;idade
Fulano;28
Joao da Silva;27
Maria;29
The reading of the file is done as follows:
import pandas as pd
df = pd.read_csv('dados.csv', sep=';')
My dataframe is generated df
with the content of the CSV:
nome idade
0 Fulano 28
1 Joao da Silva 27
2 Maria 29
So, I would like to know how I can change the name of the columns in my dataframe? I tried to use the function rename
in this way:
df.rename(columns={'nome': 'nome_completo'})
but apparently it didn’t work.
I’d like to change the name of the column nome
for nome_completo
in the dataframe.
Cat, if any answer solved your problem, you could mark one of them as accepted. Understand the importance of this link: https://pt.meta.stackoverflow.com/questions/1078/como-e-por-que-aceitar-uma-reply
– Lucas