Skip to content
Advertisement

AttributeError when applying map() for formatting

Hoping someone can advise on the AttributeError I’m receiving, as I’m not sure what is wrong with the way my code is written. I’ve seen other posts dealing with “‘DataFrame’ object has no attribute”, but it wasn’t applicable to this scenario. Using Python’s map() function to iterate and apply the same formatting across all rows and specified columns, but the map() seems to be the issue. Is there any alternative approach?

Error message:

JavaScript

Original code:

JavaScript

Advertisement

Answer

Problem is duplicated columns names. So intead Series (one column) your code return all columns with same name.

Test:

JavaScript

Solution is deduplicated columns names or remove duplicated columns names:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement