From the course: SQL Server Machine Learning Services: Python

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Challenge: Sample a data frame

Challenge: Sample a data frame

From the course: SQL Server Machine Learning Services: Python

Start my 1-month free trial

Challenge: Sample a data frame

(upbeat electronic music) - [Instructor] It's time for another challenge. You've seen a number of ways to leverage the pandas data frame functions to return useful information. The art of programming will always involve applying old skills to new situations. With that mind, here's what I'd like you to try. First, create a query that selects the CityID and CityName columns from the Application.Cities table. Then, load that into a Python data frame. Next, I want you to process the data and return 10 random records as a SQL result set. To do this, you'll need to make use of a pandas function that you haven't seen yet. It's called sample. It follows a similar syntax to many of the functions that you have seen. So my hope is is that you can apply the patterns that you know to a new problem. If you need help, you can take a look through the documentation by searching for random sample on this page of the pandas API reference. I estimate that this challenge should take 10 minutes or less…

Contents