From the course: NumPy Essential Training: 1 Foundations of NumPy
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Aggregate functions
From the course: NumPy Essential Training: 1 Foundations of NumPy
Aggregate functions
- Usually when we're faced with a large amount of data one of the first steps is to compute summary statistics for the data and the consideration. NumPy helps us do that, with a set of functions for calculating aggregates for NumPy arrays. Which take an array as an input, and by the fault, return a scalar, as output. These are statistics such as averages, standard deviation, functions for calculating the sum, and the product developments in array. Let's jump into our first example and see how we can compute the sum of all values in array. There is a simple function to achieve this called sum. First, lets import numpy as np and create a one dimensional array called first arr. Then we contain tens from 10 to 100. And then 2, two dimensional arrays called second arr that has dimensions 3 by 3. And third arr that has dimensions 2 by 5. Let's calculate the sum for all three arrays. We just need to type first arr dot sum, to calculate the sum of all values in first arr. And similarly, for…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.