dataframe - 将时间序列从 CSV 加载到 DataFrame
问题描述
是否可以从第一列是一系列日期的 CSV 创建一个 Daru DataFrame?
以下面的 CSV 为例:
time,min,max
2018-01-01,101,103
2018-01-02,102,105
2018-01-03,103,200
2018-01-04,104,109
2018-01-05,105,110
如果加载Daru::DataFrame.from_csv
它,将创建一个 5x3 DataFrame 和一个从 0 开始的数字索引,而不是一个带有 DateTimeIndex 的 5x2 DataFrame。
有没有办法指示 Daru 使用第一个向量作为DateTimeIndex
索引?
解决方案
df = Daru::DataFrame.from_csv("df.csv")
df.set_index "time"
df.index = Daru::DateTimeIndex.new(df.index)
df
<Daru::DataFrame(5x2)>
min max
2018-01-01 101 103
2018-01-02 102 105
2018-01-03 103 200
2018-01-04 104 109
2018-01-05 105 110
推荐阅读
- android - 与android studio的意图共享只显示图像而不是文本
- flutter - 处理拦截器中的 grpc 错误
- powershell - 进度条存在但不可见
- jenkins-pipeline - Jenkins管道无法访问数组
- amazon-s3 - s3:来自 CodeBuild 的 PutObject 访问被拒绝
- azure - 蓝图部署问题
- javascript - 隐藏单元格中的新行被省略,如何获得竞争的innerText?
- jfrog-cli - 我们如何在 Jfrog aql 语言规范文件中定义多个路径?
- c# - 无法将类型 system.collections.generic.list 隐式转换为 system.collections.generic.IEnumerable
- scala - HBox 未在 ScalaFX 中调整大小