将 CSV 中的时间序列加载到 DataFrame 中
Loading a time series from CSV into a 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
加载,它将创建一个具有从 0 开始的数字索引的 5x3 DataFrame,而不是具有 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
是否可以从第一列是一系列日期的 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
加载,它将创建一个具有从 0 开始的数字索引的 5x3 DataFrame,而不是具有 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