Deck 3 and 4: dtypes and .loc vs. iloc

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/6

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 3:50 PM on 8/27/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

7 Terms

1
New cards

What does df.dtypes show?

The data type of each column, e.g. int64 (whole numbers), float64 (decimals), object (text/strings), bool (True/False).

2
New cards

Why check .dtypes before analysis?

To catch numeric columns that accidentally loaded as text (e.g. due to a stray comma), which would break or silently corrupt calculations like .mean().

3
New cards

What does df.loc['AAACCT'] select?

The row labeled AAACCT → selection by label

4
New cards

What does df.iloc[0, :] select?

The first row (position 0), all columns → selection by position, regardless of labels.

5
New cards

What is the core difference between .loc and .iloc?

.loc selects by the label you can see (index name, column name); .iloc selects by numeric position (0, 1, 2...)

6
New cards

Why can .iloc give unexpected results after sorting or filtering a DataFrame?

  • Positions shift when rows are reordered or removed, so .iloc[0] gives whatever ended up first → not necessarily the row you originally meant.

  • .loc['label'] always returns that specific row regardless of ordering.


7
New cards

What does df.loc['AAACCT':'AACTGG', ['n_genes', 'cell_type']] select?

A block of rows from AAACCT to AACTGG (inclusive, by label) and just the n_genes and cell_type columns