當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python pandas.core.window.expanding.Expanding.corr用法及代碼示例

用法:

Expanding.corr(other=None, pairwise=None, ddof=1, **kwargs)

計算擴展相關性。

參數

otherSeries 或 DataFrame,可選

如果未提供,則默認為 self 並產生成對輸出。

pairwise布爾值,默認無

如果為 False,則僅使用 self 和 other 之間的匹配列,並且輸出將是 DataFrame。如果為 True,則將計算所有成對組合,並且在 DataFrame 輸入的情況下,輸出將是 MultiIndexed DataFrame。在缺少元素的情況下,將僅使用完整的成對觀察。

**kwargs

為了 NumPy 的兼容性,不會對結果產生影響。

返回

Series或DataFrame

返回類型與 np.float64 dtype 的原始對象相同。

注意

該函數使用 Pearson 的相關性定義 (https://en.wikipedia.org/wiki/Pearson_correlation_coefficient)。

other 未指定時,輸出將為自相關(例如全 1),但 DataFrame 輸入除外,其中 pairwise 設置為 True

函數將為等值序列的相關性返回NaN;這是 0/0 除法錯誤的結果。

pairwise 設置為 False 時,將僅使用 selfother 之間的匹配列。

pairwise 設置為 True 時,輸出將是一個 MultiIndex DataFrame,其中原始索引位於第一級,other DataFrame 列位於第二級。

在缺少元素的情況下,將僅使用完整的成對觀察。

相關用法


注:本文由純淨天空篩選整理自pandas.pydata.org大神的英文原創作品 pandas.core.window.expanding.Expanding.corr。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。