spark-ts TimeSeriesRDD - 如何以小时频率创建DateTimeIndex?

时间:2017-03-09 19:34:22

标签: scala apache-spark time-series cloudera

我关注cloudera blog on using spark-ts for time series analysis in scala。我想创建一个每小时频率的DateTimeIndex。博客中的示例显示了如何使用工作日频率创建DateTimeIndex,如下所示:

val dtIndex = DateTimeIndex.uniform(
  new DateTime("2015-08-03"), new DateTime("2015-09-22"), new BusinessDayFrequency(1))

我希望在github repository of DateTimeIndex.scala from author Sandy Ryza中找到解决方案,但到目前为止无法弄明白。

我如何修改上述示例以生成每小时频率的索引?

1 个答案:

答案 0 :(得分:2)

有一个HourFrequency类:

val dtIndex = DateTimeIndex.uniform(
  new DateTime("2015-08-03"), new DateTime("2015-09-22"), new HourFrequency(1))

https://github.com/sryza/spark-timeseries/blob/master/src/main/scala/com/cloudera/sparkts/Frequency.scala#L125-L129