Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions episodes/07-pandas_essential.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,15 @@ or:
print(data.iloc[0, :])
```

The `:` character by itself is shorthand to indicate all elements across that indice, but it can also be combined with index values or column headers to specify a slice of the DataArray:
Note that here we knew that Albania was the first country in the DataFrame, so we were able to ask for the first column (0). If you needed to know the column ID for a particular country, you could do this using `get_loc()`, e.g. `data.index.get_loc("France")` should tell you the column ID value for France.

The `:` character by itself is shorthand to indicate all elements across that index, but it can also be combined with index values or column headers to specify a slice of the DataArray:

```python
print(data.loc["Albania", 'gdpPercap_1962':'gdpPercap_1972'])
```

If either end of the slice definition is omitted, then the slice will run to the end of that indice (just as it does for `:` by itself):
If either end of the slice definition is omitted, then the slice will run to the end of that index (just as it does for `:` by itself):

```python
print(data.loc["Albania", 'gdpPercap_1962':])
Expand Down
6 changes: 3 additions & 3 deletions renv/profiles/lesson-requirements/renv.lock
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@
},
"knitr": {
"Package": "knitr",
"Version": "1.49",
"Version": "1.51",
"Source": "Repository",
"Type": "Package",
"Title": "A General-Purpose Package for Dynamic Report Generation in R",
Expand Down Expand Up @@ -808,7 +808,7 @@
},
"rmarkdown": {
"Package": "rmarkdown",
"Version": "2.29",
"Version": "2.31",
"Source": "Repository",
"Type": "Package",
"Title": "Dynamic Documents for R",
Expand Down Expand Up @@ -925,7 +925,7 @@
},
"xfun": {
"Package": "xfun",
"Version": "0.51",
"Version": "0.57",
"Source": "Repository",
"Type": "Package",
"Title": "Supporting Functions for Packages Maintained by 'Yihui Xie'",
Expand Down
Loading