pd.rolling_mean becoming deprecated - alternatives for ndarrays

前端 未结 5 708
自闭症患者
自闭症患者 2020-12-16 14:09

EDIT: This question was asked in 2016 and similar questions have been posted on SO years later after the functionality was finally removed, e.g. module 'pandas' has

5条回答
  •  难免孤独
    2020-12-16 14:39

    If your dimensions are homogeneous, you could try to implement an n-dimensional form of the Summed Area Table used for bidimensional images:

    A summed area table is a data structure and algorithm for quickly and efficiently generating the sum of values in a rectangular subset of a grid.

    Then, in this order, you could:

    1. Create the summed area table ("integral") of your array;
    2. Iterate to get the (quite cheap) sum of a n-dimensional kernel at a given position;
    3. Divide by the size of the n-dimensional volume of the kernel.

    Unfortunately I cannot know if this is efficient or not, but the by the given premise, it should be.

提交回复
热议问题