Introduction to K-nearest neighbors

Hi there, I’m on screen 6 of Introduction to K-nearest neighbors

import numpy as np
np.random.seed(1)

random_order = np.random.permutation(len(dc_listings))

dc_listings = dc_listings.loc[random_order]

Why is loc[] used here, considering that random_order is an array of number indexes?

The indices of dc_listings are integer numbers that start from 0. Both iloc and loc would work in this instance.

1 Like

Okay, that makes sense; thanks :slight_smile:

1 Like