diff --git a/pandas/core/frame.py b/pandas/core/frame.py index f575e49a981aa2..ddee6eb7fd0ee7 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -6672,11 +6672,8 @@ def corr(self, method='pearson', min_periods=1): Examples -------- >>> import numpy as np - >>> histogram_intersection = lambda a, b: np.minimum( - ... np.true_divide(a, a.sum()), np.true_divide(b, b.sum()) - ... ).sum() - - >>> df = pd.DataFrame([(1, 3), (0, 6), (3, 0), (1, 1)], + >>> histogram_intersection = lambda a, b: np.minimum(a, b).sum().round(decimals=1) + >>> df = pd.DataFrame([(.2, .3), (.0, .6), (.6, .0), (.2, .1)], ... columns=['dogs', 'cats']) >>> df.corr(method=histogram_intersection) dogs cats diff --git a/pandas/core/series.py b/pandas/core/series.py index 0a534e125b4702..9c253b1c0e10e9 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -1932,12 +1932,9 @@ def corr(self, other, method='pearson', min_periods=None): Examples -------- >>> import numpy as np - >>> histogram_intersection = lambda a, b: np.minimum( - ... np.true_divide(a, a.sum()), np.true_divide(b, b.sum()) - ... ).sum() - - >>> s1 = pd.Series([1, 0, 3, 1]) - >>> s2 = pd.Series([3, 6, 0, 1]) + >>> histogram_intersection = lambda a, b: np.minimum(a, b).sum().round(decimals=1) + >>> s1 = pd.Series([.2, .0, .6, .2]) + >>> s2 = pd.Series([.3, .6, .0, .1]) >>> s1.corr(s2, method=histogram_intersection) 0.3 """