开始使用免费开始使用

充电时长在变长吗?

数据科学团队目前有一个模型,会根据车辆平均充电时长预测空闲充电桩的数量。这样一来,他们就能在合适的时间提醒之前的用户回来充电。不过,团队认为自上次训练模型以来,平均充电时长可能已经发生变化。您能为他们验证一下吗?

本练习是课程的一部分

Snowflake 中的 Window Functions

查看课程

练习说明

  • 使用窗口函数计算车辆 charging_duration 的运行平均值。
  • charging_station_location 对结果进行分区。
  • charging_start_time 升序为窗口排序。
  • 将记录窗口设置为始终介于第一行和 CURRENT ROW 之间。

交互式实操练习

通过完成这段示例代码来试试这个练习。

SELECT
	user_id,
    charging_station_location,
	TO_DATE(charging_start_time),
    charging_duration,

    -- Find the running average of charging duration
    ___ OVER(
      	-- Partition the results by charging_station_location
      	___

        -- Sequence the results by charging start time in ascending order
        ORDER BY ___

        -- Create the window of records to always be between the 
      	-- first row and the current row
        ___

    ) AS running_average
FROM ELECTRIC_VEHICLES.charging;
编辑并运行代码