python-novice-gapminder icon indicating copy to clipboard operation
python-novice-gapminder copied to clipboard

Pandas DataFrames episode need section about using tuples/lists

Open rgaiacs opened this issue 8 years ago • 1 comments

http://swcarpentry.github.io/python-novice-gapminder/08-data-frames/ mentions the use of "identifiers" (numbers or strings), : and slice to select part of a dataframe. You can also use tuples/lists and I think this is a important concept that should not left as a exercise or for learners teach themselves.

We should add something like

data.ix[('Norway', 'Italy', 'Poland', 'Netherlands'), 'gdpPercap_1962':'gdpPercap_1972']

into that episode.

rgaiacs avatar Jun 16 '17 13:06 rgaiacs

Well I would like to contribute this as being a part of the carpentry instructor's checkout process. @rgaiacs has pointed out really great point to select the part of datafarme by mentioning rows and columns as lists/tuples. Also would like to mention that the latest panda's version has depreciated the use of dataframe.ix indexer because it could use both the functionality of .iloc and .loc i.e positionally index and label index respectively, and therefore to avoid the confusion we now only use the latter two. But sure the example mentioned in the above comment can be done as data.loc[data.index[['Norway', 'Italy', 'Poland', 'Netherlands']], 'gdpPercap_1962':'gdpPercap_1972']

bnitin92 avatar May 22 '20 02:05 bnitin92