I can’t read column on pandas

Asked

Viewed 115 times

0

I have this Dataframe:

             Nome          CPF      ...        Senha          Cargo
0     Silvio José  10575674451      ...        12345  Administrador
1  Carlos Alberto  10767764330      ...        12345  Administrador
2  Maria Madalena  23323234343      ...        12345     Supervisor
3    Caio Bezerra  10992329221      ...        12345     Supervisor
4  Mateus Alencar  10732393213      ...        12345     Supervisor

When I use this command pessoas_frame['CPF'] it prints the column normally. But when I use the command pessoas_frame['Idade'] he sends a message: KeyError: 'Idade'

Now if I use the command pessoas_frame.iloc[:, 2] he prints the column normally:

0    23
1    21
2    20
3    23
4    22
Name: Idade , dtype: int64

1 answer

0


I don’t know where you got these columns from, but it looks like your dataframe column is named after 'Idade ' and not 'Idade'.

Try using the command:

pessoas_frame['Idade ']

Browser other questions tagged

You are not signed in. Login or sign up in order to post.