Skip to content
This repository was archived by the owner on Feb 2, 2024. It is now read-only.

Commit 87026a5

Browse files
Rubtsowashssf
authored andcommitted
fix Series.cov (#348)
1 parent 4410e92 commit 87026a5

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

sdc/datatypes/hpat_pandas_series_functions.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3543,7 +3543,15 @@ def hpat_pandas_series_cov_impl(self, other, min_periods=None):
35433543
if len(self_arr) < min_periods:
35443544
return numpy.nan
35453545

3546-
return numpy.cov(self_arr, other_arr)[0, 1]
3546+
new_self = pandas.Series(self_arr)
3547+
3548+
ma = new_self.mean()
3549+
mb = other.mean()
3550+
3551+
if numpy.isinf(mb):
3552+
return numpy.nan
3553+
3554+
return ((self_arr - ma) * (other_arr - mb)).sum() / (new_self.count() - 1.0)
35473555

35483556
return hpat_pandas_series_cov_impl
35493557

0 commit comments

Comments
 (0)