Complete the code to select the row with label 2 using loc.
selected_row = df.loc[[1]]Using loc with the label 2 selects the row with index label 2.
Complete the code to select the third row using iloc.
selected_row = df.iloc[[1]]iloc uses zero-based integer positions, so the third row is at position 2.
Fix the code to select rows 1 to 3 (inclusive) using loc.
subset = df.loc[[1]]1:4, confusing loc (inclusive end) with iloc (exclusive end).loc slicing with labels is inclusive of both start and end, so 1:3 selects rows with index labels 1, 2, and 3.
Fill both blanks to select rows with iloc from position 0 to 2 and columns 'A' and 'B'.
subset = df.iloc[[1], [2]]
iloc uses integer slicing for rows (0:3 selects positions 0,1,2) and list of integer positions for columns ([0,1] assuming 'A' and 'B' are the first two columns).
Fill all three blanks to create a dictionary of row labels and values from column 'score' for rows where score > 50 using loc.
result = {index: row[[1]] for index, row in df.loc[df[[2]] [3] 50].iterrows()}score without quotes as a string key.< instead of > for the condition.We use 'score' as the column label in both loc filtering and row access. The condition uses > to filter scores greater than 50.