Skip to main content
Colin Jaffe/1 min read

Data Selection with LOC and ILOC in Pandas

Machine Learning Essentials

Supervised vs Unsupervised

Labeled data vs unlabeled — different problem classes.

Classification vs Regression

Predict a class label vs a continuous number.

Train/Test Split

Always evaluate on data the model never saw during training.

Hyperparameter Tuning

Grid search and cross-validation to find the best settings.

Master Machine Learning at Noble Desktop

Noble Desktop's Python Machine Learning Bootcamp covers scikit-learn, Keras, neural networks, and applied ML.

This lesson is a preview from our Data Science & AI Certificate Online (includes software) and Python Certification Online (includes software & exam). Enroll in a course for detailed lessons, live instructor support, and project-based training.

For this next part, I'd like you to get a little practice with loc and iloc. So our task is to get the last three rows and last three columns.

For this next part, I'd like you to get a little practice with loc and iloc. So our task is to get the last three rows and last three columns. As it says here, the little 3×3 at the bottom right of this data frame.

If we look up here, we're in the last three rows. We want those three rows, but specifically at these last three columns. So this little 3×3 right here is what we're intending to get.

And it should ultimately look something like this. Because the data frame—it will have its column names and row numbers. And then it will have these sets of values for each one.

Fuel Efficiency, Latest Launch, and Power Performance Factor. So your task is to do this twice: once using iloc, and then once using loc.

Get a little practice. All right, I'll see you in the next video. We'll go over the solution.

But first, give it a try yourself.