indices = [133, 22, 19, 203, 14, 1] df_by_indices = df.iloc[indices, :]
Here is what the above code is Doing:
1. We’re creating a list of indices that we want to select.
2. We’re using the .iloc method to select the rows in the dataframe that correspond to the indices in the list.
3. We’re using the : symbol to select all of the columns in the dataframe.