Sampling di Python
James Chapman
Curriculum Manager, DataCamp


| Tahun | Usia Rata-rata Prancis |
|---|---|
| 1975 | 31.6 |
| 1985 | 33.6 |
| 1995 | 36.2 |
| 2005 | 38.9 |
| 2015 | 41.2 |
coffee_ratings["total_cup_points"].mean()
82.15120328849028
coffee_ratings_first10 = coffee_ratings.head(10)
coffee_ratings_first10["total_cup_points"].mean()
89.1
import matplotlib.pyplot as plt
import numpy as np
coffee_ratings["total_cup_points"].hist(bins=np.arange(59, 93, 2))
plt.show()
coffee_ratings_first10["total_cup_points"].hist(bins=np.arange(59, 93, 2))
plt.show()
Populasi:

Sampel kenyamanan:

coffee_sample = coffee_ratings.sample(n=10)
coffee_sample["total_cup_points"].hist(bins=np.arange(59, 93, 2))
plt.show()
Populasi:

Sampel acak:

Sampling di Python