wesm / pydata-book

Materials and IPython notebooks for "Python for Data Analysis" by Wes McKinney, published by O'Reilly Media
Other
22.27k stars 15.19k forks source link

3rd Edition typo on p. 169 #164

Closed christianvye closed 1 year ago

christianvye commented 2 years ago

Since MSFT is a valid Python variable name, we can also select these columns using more concise syntax: In [285]: returns["MSFT"].corr(returns["IBM"])

should be as in 2nd Edition: returns.MSFT.corr(returns.IBM)

Otherwise there is no difference between the [283] code and the [285] code. Thanks.

wesm commented 2 years ago

I had intended to remove the uses of attributes from the 3rd edition — I will fix the text preceding the code example. Thank you!

christianvye commented 2 years ago

You are welcome. I’m enjoying the book and am using it as part of a course on Data Analytics and Visualization for an accelerated Masters program in Data Science at URI. Thanks for writing pandas!

On Tue, Nov 8, 2022 at 5:22 PM Wes McKinney @.***> wrote:

I had intended to remove the uses of attributes from the 3rd edition — I will fix the text preceding the code example. Thank you!

— Reply to this email directly, view it on GitHub https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_wesm_pydata-2Dbook_issues_164-23issuecomment-2D1307909904&d=DwMFaQ&c=dWz0sRZOjEnYSN4E4J0dug&r=AEWSxOO9YnIqcdzKn9xUfufGqw3L23xQ0zg-mve3hRg&m=PS-JnAVc_wNrBkIgWM-3EgyJtsdJbrf8hMm9hiqDD6v361_UURcHD_aWQk9qB0tG&s=2Dvw4xCDthnrhflPMVH7sRLrrIsK4mxQ3shBp1ggQMI&e=, or unsubscribe https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_A4CTDMHASYV2ZISXXPP6UODWHLHAXANCNFSM6AAAAAAR2ZVIIA&d=DwMFaQ&c=dWz0sRZOjEnYSN4E4J0dug&r=AEWSxOO9YnIqcdzKn9xUfufGqw3L23xQ0zg-mve3hRg&m=PS-JnAVc_wNrBkIgWM-3EgyJtsdJbrf8hMm9hiqDD6v361_UURcHD_aWQk9qB0tG&s=FZj2pMKzNkhLDvy_9D4cqTpOzm26W-KUta9BVSNlTyY&e= . You are receiving this because you authored the thread.Message ID: @.***>

christianvye commented 2 years ago

Found another one in the 3rd edition: In [110]: ax.title("Changes in log(m1) versus log(unemp)") should be plt.title on p. 312. Correct in the 2nd edition.

On Tue, Nov 8, 2022 at 5:52 PM Christian Vye @.***> wrote:

You are welcome. I’m enjoying the book and am using it as part of a course on Data Analytics and Visualization for an accelerated Masters program in Data Science at URI. Thanks for writing pandas!

On Tue, Nov 8, 2022 at 5:22 PM Wes McKinney @.***> wrote:

I had intended to remove the uses of attributes from the 3rd edition — I will fix the text preceding the code example. Thank you!

— Reply to this email directly, view it on GitHub https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_wesm_pydata-2Dbook_issues_164-23issuecomment-2D1307909904&d=DwMFaQ&c=dWz0sRZOjEnYSN4E4J0dug&r=AEWSxOO9YnIqcdzKn9xUfufGqw3L23xQ0zg-mve3hRg&m=PS-JnAVc_wNrBkIgWM-3EgyJtsdJbrf8hMm9hiqDD6v361_UURcHD_aWQk9qB0tG&s=2Dvw4xCDthnrhflPMVH7sRLrrIsK4mxQ3shBp1ggQMI&e=, or unsubscribe https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_A4CTDMHASYV2ZISXXPP6UODWHLHAXANCNFSM6AAAAAAR2ZVIIA&d=DwMFaQ&c=dWz0sRZOjEnYSN4E4J0dug&r=AEWSxOO9YnIqcdzKn9xUfufGqw3L23xQ0zg-mve3hRg&m=PS-JnAVc_wNrBkIgWM-3EgyJtsdJbrf8hMm9hiqDD6v361_UURcHD_aWQk9qB0tG&s=FZj2pMKzNkhLDvy_9D4cqTpOzm26W-KUta9BVSNlTyY&e= . You are receiving this because you authored the thread.Message ID: @.***>

wesm commented 1 year ago

These issues are both fixed in the notebooks and will be corrected on https://wesmckinney.com/book

pouria09 commented 6 months ago

Hi, I working on your Book "Python for Data Analysis" second edition when trying Chapter 7. Data Aggregation and Group Operations cell 53 "def peak_to_peak(arr): return arr.max() - arr.min()" grouped.agg(peak_to_peak)

I receive an error "TypeError: unsupported operand type(s) for -: 'str' and 'str'" and I have tried everything and even looked for the third edition of your book. why is this error and what is the solution???

christianvye commented 6 months ago

I didn't have any problem with that bit of code from Chapter 10, Version2.:

Data Aggregation https://jupyter.uri.edu/user/christianvye/lab/tree/ProblemSolutions/ch10.ipynb#Data-Aggregation [5]:

df

grouped = df.groupby('key1')

grouped['data1'].quantile(0.9)

[5]:

key1 a 1.668413 b -0.523068 Name: data1, dtype: float64

[6]:

def peak_to_peak(arr):

return arr.max() - arr.min()

grouped.agg(peak_to_peak)

[6]: data1data2 key1 a 2.170488 1.300498 b 0.036292 0.487276

On Fri, May 24, 2024 at 2:35 PM Pouria Rakhshan @.***> wrote:

Hi, I working on your Book "Python for Data Analysis" second edition when trying Chapter 7. Data Aggregation and Group Operations cell 53 "def peak_to_peak(arr): return arr.max() - arr.min()" grouped.agg(peak_to_peak)

I receive an error "TypeError: unsupported operand type(s) for -: 'str' and 'str'" and I have tried everything and even looked for the third edition of your book. why is this error and what is the solution???

— Reply to this email directly, view it on GitHub https://urldefense.com/v3/__https://github.com/wesm/pydata-book/issues/164*issuecomment-2130144724__;Iw!!Jh1S!kGJ2M0MlwnxBVLWzso7FmEJYCcn5bNHdIhDoOTFDO7N2PFUENnnr5-AIMdKm8OvWz3YuVVKzzNiMHmp7nhfjHAzRAZk$, or unsubscribe https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/A4CTDMCXW74DQACJF2V4I2LZD6B6RAVCNFSM6AAAAAAR2ZVIICVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMZQGE2DINZSGQ__;!!Jh1S!kGJ2M0MlwnxBVLWzso7FmEJYCcn5bNHdIhDoOTFDO7N2PFUENnnr5-AIMdKm8OvWz3YuVVKzzNiMHmp7nhfjxhsU9kQ$ . You are receiving this because you authored the thread.Message ID: @.***>

pouria09 commented 6 months ago

this is really weird, since I followed each step like its mentioned in the book and even the Jupyter Notebook, in the beginning its my IDE causing the error. I started to code on colab and later I switched to Jupyter and I have still the same error: "TypeError: unsupported operand type(s) for -: 'str' and 'str'".

anyway thanks for the quick response, I will check everything.

christianvye commented 6 months ago

Do you have “ around the function? Or is that just how you described it?

On Fri, May 24, 2024 at 4:08 PM Pouria Rakhshan @.***> wrote:

this is really weird, since I followed each step like its mentioned in the book and even the Jupyter Notebook, in the beginning its my IDE causing the error. I started to code on colab and later I switched to Jupyter and I have still the same error: "TypeError: unsupported operand type(s) for -: 'str' and 'str'".

anyway thanks for the quick response, I will check everything.

— Reply to this email directly, view it on GitHub https://urldefense.com/v3/__https://github.com/wesm/pydata-book/issues/164*issuecomment-2130284262__;Iw!!Jh1S!ksUEr9Le8HKHY9a6c3flcI-IwqujPEqG6ppMNVXndSVbpx1F2g_QAfJ9yzN4QZ7D7zQMK8GZDHSh5I4ONu7bAnj4q10$, or unsubscribe https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/A4CTDMHPJOB6OYNTWZQCWOTZD6M3BAVCNFSM6AAAAAAR2ZVIICVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMZQGI4DIMRWGI__;!!Jh1S!ksUEr9Le8HKHY9a6c3flcI-IwqujPEqG6ppMNVXndSVbpx1F2g_QAfJ9yzN4QZ7D7zQMK8GZDHSh5I4ONu7btAcpUJ8$ . You are receiving this because you authored the thread.Message ID: @.***>