This is in the Life Expectancy and GDP project, but it’s really a question about Jupyter Notebook or Python itself.
I was trying to rename a column of a Dataframe, but for some reason, Jupyter was implicitly type-casting the Dataframe to a Series object, whose rename method does not have a “columns” keyword. So I keep getting this error about the rename() method not taking a column keyword, which was making me go insane because all the documentation said that it does. But I eventually found a random comment on stackoverflow that clued me in to checking the type. And lo and behold, the Dataframe was a series.
The problem is that I have no idea why it was happening. I fixed it by running the code a few more times and clicking different cells before hitting run.
The type() function was saying Series, but then suddenly switched to Dataframe and it worked. I’m so confused…