In this lecture, I will go through mathematical and statistical methods that can be applied on by a
race either as a whole or on specific axes, mathematical methods are usually used to calculate some
aggregates or statistics that describe the data, such as minimum maximum mean, some standard deviation,
etc. To learn how we can compute this is that this sticks with no series.
Let's first import.
No, I.
Now, let's create this four by five number by a rate like this.
We created a two dimensional array with four rows and five columns filled with random numbers.
Let's compute the mean of the whole array like this.
It can also be done by passing the array as an argument for the function mean like this.
Other statistics can be computed in the same way, like the minimum value.
Or the maximum value?
Or the standard deviation?
Or cumulative sum using the function come some like this.
This comes some function is used, for example, when forming cumulative sum charts.
Another useful function is Argaman.
Argaman differs from men in that it returns the index of the minimum value, not the minimum value itself.
Let's explore it here with this array.
Let's first apply the minimum function like this.
The output is four, meaning the minimum value is four.
Let's now apply the argument function to this array like this.
The argaman function returned number eight, which means that the index of the minimum value is eight.
Additionally, Argo Max is doing the same, but its returns the index of the maximum value like this.
These arguments and arguments functions are useful in many cases in data science.
So far, we performed these functions on the whole array, but there is an option to use them on specific
axes.
For example, if you want the mean across the columns or the mean across the rows, in such case, you
need to specify the axis for the function.
For example, let's go back and display the array number one like this.
Let's now compute the sum across the rows.
This will produce a separate sum for each column.
So we have here five columns and five summits.
And as you know, axis zero represents the rose and axis one represents the columns.
As you can see, this function returned some across the rows.
That is why we specified axis to be zero.
Don't be confused here.
When you specify axis zero, this means the sum will be performed across the rows.
So the result will be the sum of the columns.
Similarly, if you specify the axis to be won, this means the sum will be performed across the columns,
which returns separate sum for each row.
And we do it like this.
You see here we have four sons, one for each role.
I hope you are not confused with this access issue.
It looks first contradicting, but when you think about it, it becomes clear.
Now, of course, any function that we have mentioned here, like the mean or maximum, et cetera,
can also be performed on a specific axis.
One last thing that I need to mention here is that these functions can also work on Boolean values,
not just on numbers.
In that case, True is considered one and false is considered zero.
For example, let's have this Boolean array.
We can find the some like this.
And it basically returns the number of true values, because as I said before, Python considers the
true as one and false as zero.
This will be useful later when you want to deal with missing values in large datasets.
I will deal with that later in this course.
But for now, it's not too important functions when dealing with missing values which are called any
and all the function.
Any will scan the Boolean array for any true value.
If at least one true value is found, it returns true.
Like this example?
On the other hand, the function all will only return true if all elements are true.
Otherwise, it's returns false, as in this example here.
And as you see, it's returned false because not all values are true.
Now consider this every.
Applying the function all should return true like this.
And as you see, it's returned to true because all values are true.
With this, we come to the end of this lecture.
In the next lecture, you will learn about sorting numbed by a race.
Thanks for watching.