Closed n2ygk closed 1 year ago
Thanks that makes sense to me
On Fri, Jan 13, 2023, 22:13 Alan Crosswell @.***> wrote:
str.strip() actually removes each character in the character class string. So .strip('gpdaPerc_') would also do the same thing and is confusing. I made a live typo during the workshop and a student asked me how was it that it still worked when I had add gdpPercap even though there's no _ between gdp and Per!
Reference: https://pandas.pydata.org/docs/reference/api/pandas.Series.str.strip.html and https://pandas.pydata.org/docs/reference/api/pandas.Series.str.replace.html
You can view, comment on, or merge this pull request online at:
https://github.com/swcarpentry/python-novice-gapminder/pull/623 Commit Summary
- e0d9d78 https://github.com/swcarpentry/python-novice-gapminder/pull/623/commits/e0d9d7861878747e526e1c7074ddbdfbe5967665 replace
str.strip()
withstr.replace()
File Changes
(1 file https://github.com/swcarpentry/python-novice-gapminder/pull/623/files)
- M _episodes/09-plotting.md https://github.com/swcarpentry/python-novice-gapminder/pull/623/files#diff-b4d9f0f8a5f4f422a2e04b1ee8189c4c24e2f2c77b6a656142af43a03e5f2665 (6)
Patch Links:
- https://github.com/swcarpentry/python-novice-gapminder/pull/623.patch
- https://github.com/swcarpentry/python-novice-gapminder/pull/623.diff
— Reply to this email directly, view it on GitHub https://github.com/swcarpentry/python-novice-gapminder/pull/623, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABLLJBPUR6KWGWGLM5T6SDDWSHAQJANCNFSM6AAAAAAT22KZ2Y . You are receiving this because you are subscribed to this thread.Message ID: @.***>
thanks for catching this! Looking more closely at this section makes me realize there are a few more areas that could use improvement:
- would be nice to embed a link to the https://pandas.pydata.org/docs/reference/api/pandas.Series.str.replace.html in the call
- I think the text "call str before replace()" beforehand isn't quite correct or at least is a bit misleading as we aren't calling
str
but instead accessing thestr
attribute of the Series class (e.g., https://pandas.pydata.org/docs/user_guide/text.html#string-methods)I'm happy to add the changes in but if you have time to also include them it would be much appreciated!
@alee so this fragment is in a python code comment (not markdown text). I guess I'll add the links to the bullet list above the code.
str.strip()
actually removes each character in the character class string. So.strip('gpdaPerc_')
would also do the same thing and is confusing. I made a live typo during the workshop and a student asked me how was it that it still worked when I had typedgdp_Percap_
even though there's no_
betweengdp
andPer
!Reference: https://pandas.pydata.org/docs/reference/api/pandas.Series.str.strip.html and https://pandas.pydata.org/docs/reference/api/pandas.Series.str.replace.html