Additional Functions and Features
In this lesson, some important functions of pandas are explored.
We'll cover the following...
Pandas functions
The following functions are explained:
-
sum(axis=0)
: This function calculates the sum of each column of aDataFrame
. -
sum(axis=1)
: This function calculates the sum of each row of aDataFrame
.
Press + to interact
import numpy as npimport pandas as pd# Declaring DataFramedf = pd.DataFrame(np.arange(9).reshape(3,3), index=['A', 'B', 'C'], columns=['A', 'B', 'C'])print("The DataFrame")print(df)print("\nThe sum of each Column:")print(df.sum(axis=0))print("\nThe sum of each Row:")print(df.sum(axis=1))
The sum of the column and row elements are clearly visible in the output.
-
min(axis=0)
: This function returns the ...