PythonForProgrammers
PythonForProgrammers copied to clipboard
ch01 error messages
I'm coming with ~2 years experience with R, but new to python. Running the first example in the book produced two errors, The first was "No module named 'seaborn`. I ran pip install seaborn which seemed to have solved that. Now I am stuck on this: "TypeError: barplot() takes from 0 to 1 positional arguments but 2 positional arguments (and 1 keyword-only argument) were given." I gather it has something to do with a missing 'self' but I'm not sure how to fix it. Any suggestion?
Here is a fix. https://github.com/pdeitel/PythonForProgrammers/blob/master/examples/ch01/RollDieDynamic.py#L17
Change line 17 to: axes = sns.barplot(x=faces, y=frequencies, palette='bright') # new bars
sorry, just seeing this. Yes. The library changed, but I thought I updated it here. Will check again.
Okay, so not to miss the teachable moment, the library no longer allows implicit, positional assignment of the x and y arguments. True? Is that a common change in python libraries within the last four years?
Correct. You must explicitly use the x and y parameter names now to call the function as I did.
instead of "faces" change to "values" axes = sns.barplot(x=values, y=frequencies, palette='bright')