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?
The error is here:
'serum sodium:sodio'
, should be'serum sodium': 'sodio'
. Since you are assigning, also do not need to use theinplace
– Paulo Marques
That’s right, thank you very much,
– Marco Aurélio Lopes Júnior
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...– Paulo Marques