Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
| Download
Views: 2116
Image: ubuntu2004
Kernel: Python 3

Exercise 3.1: Blood group

The file blood_group.csv contains the blood groups of 1000 randomly sampled people in Edinburgh.

  1. Read the data in from the file blood_group.csv.

  2. Examine the dataset by printing it out.

  3. Create a frequency table of blood groups.

  4. Create a relative frequency table of blood groups.

  5. Construct a labelled bar plot of blood groups.

%matplotlib inline import pandas as pd import matplotlib.pyplot as plt blood = pd.read_csv('blood_group.csv') blood
freq_table = blood['group'].value_counts() freq_table
rel_freq_table = blood['group'].value_counts(normalize=True) rel_freq_table
freq_table.plot.bar(facecolor='w', edgecolor='k') plt.xlabel('Blood group') plt.ylabel('Number of people') plt.title('Frequency of blood groups in 1000 people in Edinburgh');