"Display the first row in norm_reviews"

Screen Link:

My Code:


What I expected to happen:
It has to show me the first row but instead it shows me the first column

in the previous assignments, you selected a singel row from a dataframe with iloc
df.iloc[20]. according to the answer, this is not the right solution ( print(norm_reviews[:1]))

2 questions:

  1. Why does my approach give a different result?
  2. With Iloc, you have the row index first before the column index ( df.iloc[row_index, column_index])
    the answer from this assigment does the opposit.Why?

Hi jeroenstikkelorum

iloc is used for integer-based indexing. Hence df.iloc[20] will retrieve the row at index value 20.

The output of above code is

print(norm_reviews[:1]) is not the same as df.iloc[row_index, column_index]. Note the :, in the first snippet.
norm_reviews[:1] returns a slice object, i.e. the first row.

Hope its clear now.