@@ -2168,40 +2168,7 @@ def hpat_pandas_series_corr(self, other, method='pearson', min_periods=None):
21682168 ty_checker .raise_exc (min_periods , 'int64' , 'min_periods' )
21692169
21702170 def hpat_pandas_series_corr_impl (self , other , method = 'pearson' , min_periods = None ):
2171- if method not in ('pearson' , '' ):
2172- raise ValueError ("Method corr(). Unsupported parameter. Given method != 'pearson'" )
2173-
2174- if min_periods is None :
2175- min_periods = 1
2176-
2177- if len (self ._data ) == 0 or len (other ._data ) == 0 :
2178- return numpy .nan
2179-
2180- self_arr = self ._data [:min (len (self ._data ), len (other ._data ))]
2181- other_arr = other ._data [:min (len (self ._data ), len (other ._data ))]
2182-
2183- invalid = numpy .isnan (self_arr ) | numpy .isnan (other_arr )
2184- if invalid .any ():
2185- self_arr = self_arr [~ invalid ]
2186- other_arr = other_arr [~ invalid ]
2187-
2188- if len (self_arr ) < min_periods :
2189- return numpy .nan
2190-
2191- new_self = pandas .Series (self_arr )
2192- new_other = pandas .Series (other_arr )
2193-
2194- n = new_self .count ()
2195- ma = new_self .sum ()
2196- mb = new_other .sum ()
2197- a = n * (self_arr * other_arr ).sum () - ma * mb
2198- b1 = n * (self_arr * self_arr ).sum () - ma * ma
2199- b2 = n * (other_arr * other_arr ).sum () - mb * mb
2200-
2201- if b1 == 0 or b2 == 0 :
2202- return numpy .nan
2203-
2204- return a / numpy .sqrt (b1 * b2 )
2171+ return numpy_like .corr (self , other , method , min_periods )
22052172
22062173 return hpat_pandas_series_corr_impl
22072174
0 commit comments