Deck 2: NumPy Arrays

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/11

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 8:36 PM on 8/10/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

12 Terms

1
New cards

What does import numpy as np do?

Imports the NumPy library under the shortcut name np, so you can call np.something() instead of the full name.

2
New cards

What does np.loadtxt('expression.csv', delimiter=',') do?

Loads a CSV file into a NumPy array, splitting values by comma

3
New cards

What does data.shape tell you, and why check it first?

The dimensions of the array (e.g. (60, 40) = 60 rows, 40 columns); checking it first catches transposed data, duplicate loads, or empty files immediately.

4
New cards

What does data.dtype tell you?

The data type stored in the array, e.g. float64 = decimal numbers

5
New cards

Why is NumPy faster than plain Python lists for numeric work?

A NumPy array is one block of memory holding numbers of a single consistent type, which makes operations like np.mean() much faster than looping over Python lists.

6
New cards

What does data[0, :] select?

Row 0, all columns (all genes for the first cell)

7
New cards

What does data[:, 5] select?

All rows, column index 5 (gene index 5 across all cells)

8
New cards

What does data[0:10, 0:4] select?

A block: rows 0–9, columns 0–3

9
New cards

What is the general indexing pattern for NumPy arrays?

data[rows, columns] → a single number picks one row/column, : means "all," a:b means a slice

10
New cards

What does axis=0 collapse when used in np.mean(data, axis=0)?

It collapses down the rows, giving one result per column (per gene)

11
New cards

What does axis=1 collapse when used in np.mean(data, axis=1)?

It collapses across the columns, giving one result per row (per cell)

12
New cards

Memory trick for remembering axis=0 vs axis=1?

The axis number tells you which dimension gets "squashed" — axis 0 squashes rows, axis 1 squashes columns