Correlation-1
Sat 17 May 2025
import pyutil as pyu
pyu.get_local_pyinfo()
'conda env: ml312-2024; pyv: 3.12.7 | packaged by Anaconda, Inc. | (main, Oct 4 2024, 13:27:36) [GCC 11.2.0]'
print(pyu.ps2("pandas"))
pandas==2.2.3
import pandas as pd
import numpy as np
def histogram_intersection(a, b):
v = np.minimum(a, b).sum().round(decimals=1)
return v
df = pd.DataFrame([(.2, .3), (.0, .6), (.6, .0), (.2, .1)],
columns=['dogs', 'cats'])
cor_result = df.corr(method=histogram_intersection)
cor_result
| dogs | cats | |
|---|---|---|
| dogs | 1.0 | 0.3 |
| cats | 0.3 | 1.0 |
Score: 5
Category: pandas