swcarpentry / python-novice-gapminder

Plotting and Programming in Python
http://swcarpentry.github.io/python-novice-gapminder/
Other
163 stars 427 forks source link

Revise section on dataframe slicing #555

Closed henrikaskj closed 1 year ago

henrikaskj commented 3 years ago

I would suggest revising the section "Use : on its own to mean all columns or all rows", as it isn't strictly necessary to know that a colon without begin and end value results in a whole list (cf. thing[:] in the exercise in episode 2). One could instead focus on ​data.loc["Albania"] and data["gdpPercap_1952"], and add an explanation of how to select non-continuous rows and columns, e. g. data.loc[["Albania", "Turkey"]]

martinosorb commented 1 year ago

If I understand what this refers to, the exercise asks this just as one of many examples that showcase how a slice might look like. Knowing that : refers to everything is actually useful in syntax like thing[:, 5]. I'm closing this if there are no further comments, thank you for discussing this.