Skip to content

Commit a399a1e

Browse files
committed
Addd testcases, updated documentation, did not add scaling (ignore previous commit msg)
1 parent 611a351 commit a399a1e

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

doc/source/whatsnew/v3.0.0.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ Other enhancements
170170
- :func:`read_spss` now supports kwargs to be passed to pyreadstat (:issue:`56356`)
171171
- :func:`read_stata` now returns ``datetime64`` resolutions better matching those natively stored in the stata format (:issue:`55642`)
172172
- :meth:`DataFrame.agg` called with ``axis=1`` and a ``func`` which relabels the result index now raises a ``NotImplementedError`` (:issue:`58807`).
173-
- :meth:`DataFrame.corr` now uses two pass Welford's Method to improve numerical stability with precision for very large/small values (:issue:`59652`)
173+
- :meth:`DataFrame.corr` now uses first value as reference to improve numeric stability (:issue:`59652`)
174174
- :meth:`Index.get_loc` now accepts also subclasses of ``tuple`` as keys (:issue:`57922`)
175175
- :meth:`Styler.set_tooltips` provides alternative method to storing tooltips by using title attribute of td elements. (:issue:`56981`)
176176
- Added missing parameter ``weights`` in :meth:`DataFrame.plot.kde` for the estimation of the PDF (:issue:`59337`)

pandas/_libs/algos.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ def nancorr(const float64_t[:, :] mat, bint cov=False, minp=None):
363363
for yi in range(xi+1):
364364
# Welford's method for the variance-calculation
365365
# https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
366-
# Changed to Welford's two-pass for improved numeric stability
366+
# Use first valid value as reference to improve numeric stability
367367
nobs = ssqdmx = ssqdmy = cxy = meanx = meany = 0
368368
ref_set = False
369369
for i in range(N):

pandas/tests/frame/methods/test_cov_corr.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,7 @@ def test_cov_with_missing_values(self):
506506
np.array([[1e-8, 3.42e-8], [2e-9, 3e-8]], dtype=np.longdouble),
507507
np.array([[1e12, 1e-8], [1e12 + 1e-3, 2e-8]], dtype=np.longdouble),
508508
np.array([[0.0, 1e-12], [1e-14, 0.0]], dtype=np.longdouble),
509+
np.array([[1e15, 1e15 + 1e-3], [1e-20, 2e-20]], dtype=np.longdouble),
509510
]
510511

511512
@pytest.mark.parametrize("values", pair_cases)
@@ -516,6 +517,13 @@ def test_pair_correlation(self, values):
516517
tm.assert_frame_equal(result, expected)
517518

518519
multi_cases = [
520+
np.array(
521+
[
522+
[30.0, 30.100000381469727, 30.2],
523+
[116.80000305175781, 116.8000030517578, 116.9000030517578],
524+
],
525+
dtype=np.longdouble,
526+
),
519527
np.array(
520528
[[1e12, 1e-8, 5.5], [1e12 + 1e-3, 2e-8, 5.50000001]], dtype=np.longdouble
521529
),

0 commit comments

Comments
 (0)