1. The Importance of Data Visualization and Data Exploration
Activity 1.01: Using NumPy to Compute the Mean, Median, Variance, and Standard Deviation of a Dataset
Solution:
- Import NumPy:
import numpy as np
- Load the
normal_distribution.csv
dataset by using thegenfromtxt
method from NumPy:dataset = np.genfromtxt('../../Datasets/normal_distribution.csv', \ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â delimiter=',')
- First, print a subset of the first two rows of the dataset:
dataset[0:2]
The output of the preceding code is as follows:
- Load the dataset and calculate the mean of the third row. Access the third row by using index 2,
dataset[2]
:np.mean(dataset[2])
The output of the preceding code is as follows:
100.20466135250001
- Index the last element of an ndarray in the same way a regular Python list can be...