Padas Rolling.mean()显示不同的结果

时间:2019-03-08 16:29:33

标签: python pandas

我是python的新手,程序MainCommonFunctions中有两个方法。

Main下,我从CommonFunctions调用函数名称技术

@staticmethod
def tech(df, ACslow_period = None, ACfast_period = None):
        slow = pd.Series(((df[2] + df[3]) / 2).rolling(window=ACslow_period).mean())
        fast = pd.Series(((df[2] + df[3]) / 2).rolling(window=ACfast_period).mean())
        df[40] = pd.Series(fast - slow)
        df[41] = pd.Series(((df[40])).rolling(ACfast_period).mean())
        df[52] = (pd.Series(df[40] - df[41])))

        return (df)

当我直接从文件中测试公式时,结果是:

self.CommonFunctions.tech(df, ACslow_period = 340, ACfast_period = 30)

           40             41             52     
    0.000000109858 0.000000063136 0.000000046722  
    0.000000111809 0.000000064952 0.000000046857  
    0.000000113985 0.000000066986 0.000000046999 

但是当我运行程序时,结果是:

self.CommonFunctions.tech(df, ACslow_period = 340, ACfast_period = 30)

           40             41             52     
    -0.000000109858 0.000000000000 0.000000000000  
    -0.000000111809 0.000000000000 0.000000000000  
    -0.000000113985 0.000000000000 0.000000000000

使用以下数据:

file = https://pastebin.com/raw/WtBu2zh2

  • Python 3.5.2
  • 熊猫0.23.4
  • Ubuntu 16.04

有人知道为什么结果会有所不同吗?

提前谢谢!

0 个答案:

没有答案