nmalkin/plot-likert

DataFrame plotting doesn't work anymore with newer versions of Pandas

Closed this issue · 4 comments

When trying to plot a Pandas (pd) DataFrame, I run into the error:
TypeError: DataFrame.set_axis() got an unexpected keyword argument 'inplace'.
This is due to line 251 in plot_likert.py:
df = df.set_axis(new_labels, axis=1, inplace=False)

In earlier versions of pd, the inplace argument is used and has a default value of False. However, in newer versions, the argument is not used anymore. (https://pandas.pydata.org/docs/whatsnew/v1.5.0.html#:~:text=Deprecated%20the%20inplace%20keyword%20in%20DataFrame.set_axis()%20and%20Series.set_axis()%2C%20use%20obj%20%3D%20obj.set_axis(...%2C%20copy%3DFalse)%20instead%20(GH48130)) Therefore, when this piece of code is run, it throws the TypeError.

The fix is trivial, change line 251 of the plot_likert.py file to:
df = df.set_axis(new_labels, axis=1, copy=False)

Making this change in my local installation of the library fixes the problem. However, it would be nice if the library is still usable with newer versions of pd for everyone. From what I've seen, this is the best Likert-scale plot library out there!

I see now that it has already been fixed in the version that is on Github. The version I downloaded recently using pip install plot-likert doesn't have this change yet.

The fix is now available in the main release (as of v0.5.0).
Anyone experiencing this issue should make sure to update to the latest version (pip install --upgrade plot-likert). Sorry it took so long to get this out there!

Thank you so much @nmalkin - the issue was me - I did a pip install but didn't restart my Jupyter server! (inserts more coffee to continue).

Thank you so much for this tool - it is so helpful. Do you have a Kofi or a Paypal - I'd like to say thank you with money.

That's very kind, @KathyReid! Just knowing that so many people around the world use this software is rewarding enough. I'm fortunate enough to have a good job, so I'd like to encourage you to instead donate to a charity of your choice. If nothing comes to mind, may I suggest a local animal shelter? Thanks again and best of luck with your PhD! ☕