In python, we can calculate the covariance using cov() function as below.

import pandas as pd

import numpy as np

# Setting a seed so the example is reproducible

np.random.seed(123)

df = pd.DataFrame(np.random.randint(low= 0, high= 20, size= (5, 2)),

columns= ['X', 'Y'])

df[['X', 'Y']].cov()