Error renaming columns in dataset using pandas

Asked

Viewed 51 times

0

While trying to rename the dataset columns using pandas,

SyntaxError: expression cannot contain assignment, perhaps you meant "=="?

Below the error with the line of code I’m using:

File "<ipython-input-25-b3eccf173f1d>", line 1
    doencasCardiovasculares = doencasCardiovasculares.rename(columns={'age':'idade', 'anaemia':'anemia', 'creatinine_phosphokinase':'creatinofosfoquinase', 
'ejection_fraction':'fraçao de ejeção', 'high_blood_pressure':'hipertensão', 
'platelets':'plaquetas', 'serum_creatinine':'creatinina', 'serum sodium:sodio', 
'sex':'sexo', 'smoking':'fuma', 'time':'periodo de acompanhameno', 
'DEATH_EVENT':'morte durante o acompanhamento'}, inplace=True)
                                                             ^
SyntaxError: expression cannot contain assignment, perhaps you meant "=="?

To which exact attribution the error is accusing which I am referring?

  • 1

    The error is here: 'serum sodium:sodio', should be 'serum sodium': 'sodio'. Since you are assigning, also do not need to use the inplace

  • That’s right, thank you very much,

  • 4

    Tip: Whenever the error Pointer (^) is pointing to the last character of the line, means it is syntax error, usually missing carcter, quotation marks in the wrong place, etc...

No answers

Browser other questions tagged

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