Skip to content

Commit 4fd5ca1

Browse files
committed
Logic error in sub-setting array of ndarray
1 parent f101591 commit 4fd5ca1

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/.quarto/
22
/site/
3+
*.ipynb

docs/05-dicts.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,23 @@ Combine dictionary access and DataFrame indexing:
147147
data["expression"].loc["Gata1", :]
148148
```
149149

150+
But this does not work like that - does it?
151+
152+
Remember what ``data["expression"]`` is - a ndarray that is very efficient for calculations.
153+
But it lacks row and column names. We have stored row and column data in ``genes`` and ``samples``. Actually the gene names are stored in the rownames of the genes object.
154+
155+
```python
156+
print (data['genes'].index)
157+
data['genes'].index == "Gata1"
158+
```
159+
160+
Do you remember how to subset a ndarray using a boolean array? Try it!
161+
162+
??? exercise "Solution:"
163+
```python
164+
data['expression'][ data['genes'].index == "Gata1" ]
165+
```
166+
150167
---
151168

152169
# Modifying a dictionary

0 commit comments

Comments
 (0)