Skip to content

Remove blank lines-->fix cookbook rendering issue #23144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions doc/source/cookbook.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1234,25 +1234,19 @@ The `method` argument within `DataFrame.corr` can accept a callable in addition
n = len(x)
a = np.zeros(shape=(n, n))
b = np.zeros(shape=(n, n))

for i in range(n):
for j in range(i + 1, n):
a[i, j] = abs(x[i] - x[j])
b[i, j] = abs(y[i] - y[j])

a += a.T
b += b.T

a_bar = np.vstack([np.nanmean(a, axis=0)] * n)
b_bar = np.vstack([np.nanmean(b, axis=0)] * n)

A = a - a_bar - a_bar.T + np.full(shape=(n, n), fill_value=a_bar.mean())
B = b - b_bar - b_bar.T + np.full(shape=(n, n), fill_value=b_bar.mean())

cov_ab = np.sqrt(np.nansum(A * B)) / n
std_a = np.sqrt(np.sqrt(np.nansum(A**2)) / n)
std_b = np.sqrt(np.sqrt(np.nansum(B**2)) / n)

return cov_ab / std_a / std_b

df = pd.DataFrame(np.random.normal(size=(100, 3)))
Expand Down