pandas中的意外行为使用offset来滚动相关性

时间:2018-05-19 18:54:36

标签: python pandas

这是输入pandas DataFrame:

  io.fabric.sdk.android.g.a(InitializationTask.java:28) 
                                                 at io.fabric.sdk.android.services.concurrency.a$2.call(AsyncTask.java:311) 
                                                 at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
                                                 at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422) 
                                                 at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
                                                 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
                                                 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
                                                 at java.lang.Thread.run(Thread.java:841) 
    05-19 23:12:35.600 2141-2179/? E/Answers: Failed to retrieve settings
    05-19 23:12:36.100 2141-2141/? E/dalvikvm: Could not find class 'com.cloudtech.ads.core.AdGuardService', referenced from method com.cloudtech.ads.core.CTService.b
    05-19 23:12:36.220 646-891/? E/NetworkScheduler: Unrecognised action provided: android.intent.action.PACKAGE_REPLACED
    05-19 23:12:36.240 646-2113/? E/dalvikvm: Could not find class 'android.net.NetworkScoreManager', referenced from method wpj.a
    05-19 23:12:36.240 646-2113/? E/dalvikvm: Could not find class 'android.net.NetworkScoreManager', referenced from method wpj.c
    05-19 23:13:01.150 1554-1591/? E/GooglePlayServicesUtil: The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
    05-19 23:13:01.160 1554-1591/? E/Finsky: [86] com.google.android.finsky.deviceconfig.k.a(15): Unable to fetch checkin consistency token: GooglePlayServices is unavailable 2
    05-19 23:13:01.230 1554-1945/? E/GooglePlayServicesUtil: The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
    05-19 23:13:01.250 1554-1554/? E/GooglePlayServicesUtil: The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
    05-19 23:13:01.250 1554-2670/? E/GooglePlayServicesUtil: The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
    05-19 23:13:01.290 1554-1554/? E/GooglePlayServicesUtil: The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
    05-19 23:13:01.300 1554-2140/? E/GooglePlayServicesUtil: The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
    05-19 23:13:01.310 1554-1554/? E/Finsky: [1] com.google.android.finsky.wear.x.a(3): onConnectionFailed: ConnectionResult{statusCode=SERVICE_VERSION_UPDATE_REQUIRED, resolution=null, message=null}
    05-19 23:13:01.400 1554-1617/? E/GooglePlayServicesUtil: The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
    05-19 23:13:01.400 1554-2667/? E/GooglePlayServicesUtil: The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
    05-19 23:13:01.400 1554-2667/? E/Finsky: [121] com.google.android.finsky.deviceconfig.k.a(15): Unable to fetch checkin consistency token: GooglePlayServices is unavailable 2
    05-19 23:13:01.480 1554-1554/? E/dalvikvm: Could not find class 'android.content.pm.PackageInstaller$SessionParams', referenced from method com.google.android.finsky.splitinstallservice.bz.a
    05-19 23:13:01.550 1554-1620/? E/Finsky: [101] com.google.android.finsky.splitinstallservice.bj.a(76): Deferred uninstall works only for L+
    05-19 23:13:01.560 1554-1620/? E/Finsky: [101] com.google.android.finsky.splitinstallservice.aa.a(3): Can't schedule deferred install. No modules found.
    05-19 23:13:02.450 1554-1621/? E/GooglePlayServicesUtil: The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
    05-19 23:13:02.450 1554-2700/? E/GooglePlayServicesUtil: The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
    05-19 23:13:33.440 171-3242/? E/AudioSink: received unknown event type: 1 inside CallbackWrapper !
    05-19 23:13:33.440 2082-2082/myapp.apps.goo.myapp E/MediaPlayer: Should have subtitle controller already set
    05-19 23:13:37.760 3327-3327/? E/dalvikvm: Could not find class 'android.app.Notification$Action$Builder', referenced from method com.facebook.a.a.a.a
    05-19 23:13:37.790 3327-3327/? E/b: Starting ANR detector for process: com.facebook.lite
    05-19 23:13:37.810 646-1679/? E/NetworkScheduler.ATC: Provided calling package not found: com.google.android.apps.photos



 please help

为什么这两个会返回不同的结果?

df = pd.DataFrame({'x':(1,2), 'y':(2,3)},
                  index=[pd.Timestamp('20180101'), pd.Timestamp('20180102')])

窗口是int还是offset都不重要,因为两种情况下移动窗口的大小都是1。 感谢。

1 个答案:

答案 0 :(得分:0)

如果您深入了解Pandas代码并将其关注到window.py,您将进入:

    def _get_corr(a, b):

        a = a.rolling(window=window, min_periods=self.min_periods,
                      freq=self.freq, center=self.center)
        b = b.rolling(window=window, min_periods=self.min_periods,
                      freq=self.freq, center=self.center)

        return a.cov(b, **kwargs) / (a.std(**kwargs) * b.std(**kwargs))

如果在示例中打印出window和min_periods的值

df.rolling(window='1d').corr()

窗口= 86400000000000,min_periods = 1,而

df.rolling(window=1).corr()

有window = 1且min_periods = None。

您的索引是dtype ='datetime64 [ns]'

因此,看起来'1d'被翻译成24 * 60 * 60 * 1000000000或每天纳秒数。所以这与'1d'相同。

df.rolling(window=86400000000000, min_periods=1).corr()