...

/

Additional Functions and Features

Additional Functions and Features

In this lesson, some important functions of pandas are explored.

Pandas functions

The following functions are explained:

  1. sum(axis=0) : This function calculates the sum of each column of a DataFrame.

  2. sum(axis=1) : This function calculates the sum of each row of a DataFrame.

Press + to interact
import numpy as np
import pandas as pd
# Declaring DataFrame
df = 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.

  1. min(axis=0) : This function returns the ...