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.
Deze oefening maakt deel uit van de cursus
Sampling in Python
Oefeninstructies
- Sample 70 rows from
attrition_popusing simple random sampling, setting the random seed to18900217. - Print the sample dataset,
attrition_samp. What do you notice about the indices?
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
# Sample 70 rows using simple random sampling and set the seed
attrition_samp = ____
# Print the sample
____