PythonForProgrammers icon indicating copy to clipboard operation
PythonForProgrammers copied to clipboard

ch01 error messages

Open mbjohnsonmn opened this issue 3 years ago • 5 comments
trafficstars

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? ch01 example errors

mbjohnsonmn avatar Nov 08 '22 14:11 mbjohnsonmn

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

robb-romans avatar Nov 16 '22 00:11 robb-romans

sorry, just seeing this. Yes. The library changed, but I thought I updated it here. Will check again.

pdeitel avatar Nov 16 '22 00:11 pdeitel

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?

mbjohnsonmn avatar Nov 16 '22 01:11 mbjohnsonmn

Correct. You must explicitly use the x and y parameter names now to call the function as I did.

pdeitel avatar Nov 16 '22 01:11 pdeitel

instead of "faces" change to "values" axes = sns.barplot(x=values, y=frequencies, palette='bright')

robscurity avatar Mar 30 '23 17:03 robscurity