Complete the code to select the first row of the DataFrame using iloc.
first_row = df.iloc[[1]]The first row in pandas DataFrame is at position 0, so df.iloc[0] selects it.
Complete the code to select the first three rows of the DataFrame using iloc.
subset = df.iloc[[1]]Using slice 0:3 with iloc selects rows at positions 0, 1, and 2 (first three rows).
Fix the error in the code to select the last two rows using iloc.
last_two = df.iloc[[1]]Using iloc with slice -2: selects the last two rows by position. Brackets or df slicing won't work with iloc.
Fill both blanks to select rows 1 to 3 and columns 0 to 2 using iloc.
subset = df.iloc[[1], [2]]
Rows 1 to 3 are selected with slice 1:4 (stop exclusive). Columns 0 to 2 are selected with 0:3.
Fill all three blanks to create a dictionary comprehension that maps each word to its length only if length is greater than 3.
lengths = { [1] : [2] for [3] in words if len([3]) > 3 }The comprehension maps each word to its length. 'word' is the variable, 'len(word)' is the value, and 'word' is used in the loop.