From the course: Complete Guide to Advanced SQL Server

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

Challenge: Sample a DataFrame

Challenge: Sample a DataFrame

It's time for another challenge. You've seen a number of ways to leverage the pandas DataFrame functions to return useful information. The art of programming will always involve applying old skills to new situations. With that in 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 DataFrame. 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, and in the next movie, I'll show you my…

Contents