Simple random sampling
The simplest method of sampling a population is the one you've seen already. It is known as simple random sampling (sometimes abbreviated to "SRS"), and involves picking rows at random, one at a time, where each row has the same chance of being picked as any other.
In this chapter, you'll apply sampling methods to a synthetic (fictional) employee attrition dataset from IBM, where "attrition" in this context means leaving the company.
attrition_pop
is available; pandas
as pd
is loaded.
This exercise is part of the course
Sampling in Python
Exercise instructions
- Sample 70 rows from
attrition_pop
using simple random sampling, setting the random seed to18900217
. - Print the sample dataset,
attrition_samp
. What do you notice about the indices?
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Sample 70 rows using simple random sampling and set the seed
attrition_samp = ____
# Print the sample
____