Return the sum of the values for the requested axis.
Prototype:
<DataFrame_Obj>.sum ( [axis = 0 or ‘rows’ | 1 or ‘columns’ ] )
The summation functions sum() is a descriptive function which is used to give the sum of rows or columns as specifies in axis. If axis parameter is not provided the default axis is 0 or ‘rows’. That means by default sum of rows will be provided.
This function retuens the sum of each all the elemnets in the form of Series.
Note:- Here the axis='rows' menas sum of all the elemnets in different rows, not in a sing row vise-versa for axis='columns'.
Default axis is rows:
Using axis = 'rows' will provide the same output as above. You can use axis = 0 also.
Using axis = 'columns' or axis = 1. You can see the sum of all the columns has been printed with row indexes.
<DataFrame_Obj>.sum ( [axis = 0 or ‘rows’ | 1 or ‘columns’ ] )
The summation functions sum() is a descriptive function which is used to give the sum of rows or columns as specifies in axis. If axis parameter is not provided the default axis is 0 or ‘rows’. That means by default sum of rows will be provided.
This function retuens the sum of each all the elemnets in the form of Series.
Note:- Here the axis='rows' menas sum of all the elemnets in different rows, not in a sing row vise-versa for axis='columns'.
Default axis is rows:
Using axis = 'rows' will provide the same output as above. You can use axis = 0 also.
Using axis = 'columns' or axis = 1. You can see the sum of all the columns has been printed with row indexes.
No comments:
Post a Comment