Sampling in Python
James Chapman
Curriculum Manager, DataCamp
Year | Average French Age |
---|---|
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()
Population:
Convenience sample:
coffee_sample = coffee_ratings.sample(n=10)
coffee_sample["total_cup_points"].hist(bins=np.arange(59, 93, 2))
plt.show()
Population:
Random Sample:
Sampling in Python