3

我的数据集包含温度值。我想进行最小可变性检查。我想检查 3 个连续的温度值是否相对于每个定义的阈值 (.05) 没有变化,然后用最后三个观察值的平均值替换它们。

4

1 回答 1

4
   WITH A as (
   SELECT ambtemp,
          date_trunc('hour', dt)+
          CASE WHEN date_part('minute', dt) >= 6
          THEN interval '6 minutes'
          ELSE interval '0 minutes'
            END as t
          FROM temm),

              B as(
                  SELECT ambtemp,t,

   max(ambtemp::float(23)) OVER (PARTITION BY t) as max_temp,
   min(ambtemp::float(23)) OVER (PARTITION BY t) as min_temp
        FROM A)

          SELECT *

              FROM B
              WHERE (max_temp - min_temp) <= 0.5
于 2012-11-26T18:36:51.807 回答