Skip to main content

Sampling in Python

Learn to draw conclusions from limited data using Python and statistics. This course covers everything from random sampling to stratified and cluster sampling.

Start Course for Free
4 Hours15 Videos51 Exercises4000 XP

Create Your Free Account



By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA. You confirm you are at least 16 years old (13 if you are an authorized Classrooms user).

Loved by learners at thousands of companies

Course Description

Sampling in Python is the cornerstone of inference statistics and hypothesis testing. It's a powerful skill used in survey analysis and experimental design to draw conclusions without surveying an entire population. In this Sampling in Python course, you’ll discover when to use sampling and how to perform common types of sampling—from simple random sampling to more complex methods like stratified and cluster sampling. Using real-world datasets, including coffee ratings, Spotify songs, and employee attrition, you’ll learn to estimate population statistics and quantify uncertainty in your estimates by generating sampling distributions and bootstrap distributions.

  1. 1

    Bias Any Stretch of the Imagination


    Learn what sampling is and why it is so powerful. You’ll also learn about the problems caused by convenience sampling and the differences between true randomness and pseudo-randomness.

    Play Chapter Now
    Living the sample life
    50 xp
    Reasons for sampling
    50 xp
    Simple sampling with pandas
    100 xp
    Simple sampling and calculating with NumPy
    100 xp
    A little too convenient
    50 xp
    Are the findings from this sample generalizable?
    100 xp
    Are these findings generalizable?
    100 xp
    How does Sue do sampling?
    50 xp
    Generating random numbers
    100 xp
    Understanding random seeds
    100 xp


Coffee ratingsSpotify song attributesEmployee attrition


chesterismayDr. Chester Ismayamy-4121b590-cc52-442a-9779-03eb58089e08Amy Peterson
James Chapman Headshot

James Chapman

Content Developer, DataCamp

James is a Content Developer at DataCamp. He has a Master's degree in Physics and Astronomy from Durham University, where he specialized in quasar detection and tutored Math and English. He joined DataCamp as a learner in 2018, and the data skills learned on DataCamp were quickly integrated into his scientific projects. In his spare time, he enjoys restoring retro toys and electronics.

Follow James on LinkedIn
See More

What do other learners have to say?

I've used other sites—Coursera, Udacity, things like that—but DataCamp's been the one that I've stuck with.

Devon Edwards Joseph
Lloyds Banking Group

DataCamp is the top resource I recommend for learning data science.

Louis Maiden
Harvard Business School

DataCamp is by far my favorite website to learn from.

Ronald Bowers
Decision Science Analytics, USAA