Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Rename function in Python

Now I’m trying to learn about pandas package in python.
but using rename function, I have some problem.

        mushroom = pd.read_csv('./mushroom/agaricus-lepiota.data', header=None)
        mushroom = pd.DataFrame(mushroom)
        mushroom.rename(columns={'0', 'edibility', '5', 'odor'})

I’m trying to rename column name 0, 5 to ‘edibility’, ‘odor’.
But I got It’s error, not allowed to get callable set function.
How can I fix it?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

I can help you.
You seems to miss some grammar on third row.
mushroom.rename(columns={0: ‘edibility’, 5: ‘odor’})

in a short, in case of index rename, don’t use string symbol and don’t forget : grammar.
Good luck.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading