Skip to content

Commit 0f48bbf

Browse files
committed
markdown source builds
Auto-generated via `{sandpaper}` Source : d6519d9 Branch : main Author : Andrew Gait <andrew.gait@manchester.ac.uk> Time : 2026-04-13 13:20:12 +0000 Message : Merge pull request #59 from UoMResearchIT/23-add-note-on-getting-index-from-name Update to add get_loc explainer
1 parent c8f007d commit 0f48bbf

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

07-pandas_essential.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,19 @@ or:
128128
print(df.iloc[0, :])
129129
```
130130

131-
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:
131+
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. to get the column ID value for France:
132+
133+
```python
134+
df.index.get_loc("France")
135+
```
136+
137+
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:
132138

133139
```python
134140
print(df.loc["Albania", 'gdpPercap_1962':'gdpPercap_1972'])
135141
```
136142

137-
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):
143+
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):
138144

139145
```python
140146
print(df.loc["Albania", 'gdpPercap_1962':])

md5sum.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"episodes/04-software_package_management.md" "62db2ba2a4291e16d2bdd07b77bfc961" "site/built/04-software_package_management.md" "2025-04-15"
1111
"episodes/05-defensive_programming.md" "6d48a7e584a970aacdad58a28b0b9570" "site/built/05-defensive_programming.md" "2026-04-13"
1212
"episodes/06-units_and_quantities.md" "7e259f66d6f8889505c252a04082481f" "site/built/06-units_and_quantities.md" "2026-04-13"
13-
"episodes/07-pandas_essential.md" "443db701e191bb47de503d890d31d69f" "site/built/07-pandas_essential.md" "2026-04-13"
13+
"episodes/07-pandas_essential.md" "53da61ecedb6dcb8735ab4cc6fbe0f99" "site/built/07-pandas_essential.md" "2026-04-13"
1414
"instructors/instructor-notes.md" "a59fd3b94c07c3fe3218c054a0f03277" "site/built/instructor-notes.md" "2025-04-15"
1515
"learners/discuss.md" "2758e2e5abd231d82d25c6453d8abbc6" "site/built/discuss.md" "2025-04-15"
1616
"learners/reference.md" "28853696c21dd22dfb883e9c241e95fb" "site/built/reference.md" "2025-04-15"

0 commit comments

Comments
 (0)