loc do when selecting rows in a DataFrame?loc selects rows by their labels or index names. It includes the last label in slicing.
iloc differ from loc when selecting rows?iloc selects rows by their integer position, starting at 0. It excludes the last index in slicing.
df.loc[2:4] return if the DataFrame index is [0, 1, 2, 3, 4, 5]?Rows with index labels 2, 3, and 4 inclusive.
df.iloc[2:4] return if the DataFrame index is [0, 1, 2, 3, 4, 5]?Rows at integer positions 2 and 3 (index labels 2 and 3), excluding position 4.
loc select rows using boolean conditions?Yes, loc can select rows by passing a boolean mask (True/False values) to filter rows.
iloc selects rows by integer position, starting at 0.
df.loc[1:3] include when selecting rows?loc includes the last label in slicing, so rows 1, 2, and 3 are included.
df.iloc[1:3] select?iloc selects by position 1 and 2, which correspond to labels 'b' and 'c'.
loc slicing?loc includes the last label when slicing rows.
loc?Use a boolean mask inside loc to filter rows by condition.
loc and iloc when selecting rows in a DataFrame.loc.