MulaiMulai sekarang secara gratis

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.

Latihan ini adalah bagian dari kursus

Sampling in Python

Lihat Kursus

Petunjuk latihan

  • Sample 70 rows from attrition_pop using simple random sampling, setting the random seed to 18900217.
  • Print the sample dataset, attrition_samp. What do you notice about the indices?

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Sample 70 rows using simple random sampling and set the seed
attrition_samp = ____

# Print the sample
____
Edit dan Jalankan Kode