Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
The Data Visualization Workshop

You're reading from   The Data Visualization Workshop A self-paced, practical approach to transforming your complex data into compelling, captivating graphics

Arrow left icon
Product type Paperback
Published in Jul 2020
Publisher Packt
ISBN-13 9781800568846
Length 536 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Mario Döbler Mario Döbler
Author Profile Icon Mario Döbler
Mario Döbler
Tim Großmann Tim Großmann
Author Profile Icon Tim Großmann
Tim Großmann
Arrow right icon
View More author details
Toc

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:

  1. Import NumPy:
    import numpy as np
  2. Load the normal_distribution.csv dataset by using the genfromtxt method from NumPy:
    dataset = np.genfromtxt('../../Datasets/normal_distribution.csv', \
                            delimiter=',')
  3. First, print a subset of the first two rows of the dataset:
    dataset[0:2]

    The output of the preceding code is as follows:

    Figure 1.57: First two rows of the dataset

  4. 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
  5. Index the last element of an ndarray in the same way a regular Python list can be...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime