我有一个 excelfile,我将其读入 Dataframe。
using DataFrames, XLSX
df = DataFrame(XLSX.readtable("Stocks/WIHL-Wihlborgs.xlsx", "PriceMonth")...)
│ Row │ Date │ Openprice │ Highprice │ Lowprice │ Closeprice │ Volume │
│ │ Any │ Any │ Any │ Any │ Any │ Any │
├─────┼────────────┼───────────┼───────────┼──────────┼────────────┼──────────┤
│ 1 │ 2020-12-23 │ 189.1 │ 189.7 │ 170.3 │ 181.5 │ 4170122 │
│ 2 │ 2020-11-30 │ 160.0 │ 191.6 │ 158.0 │ 189.1 │ 8006506 │
│ 3 │ 2020-10-30 │ 178.4 │ 184.3 │ 151.2 │ 160.6 │ 6760931 │
│ 4 │ 2020-09-30 │ 138.5 │ 178.8 │ 137.9 │ 177.5 │ 9005351 │
│ 5 │ 2020-08-31 │ 147.2 │ 152.1 │ 137.2 │ 138.3 │ 4865386 │
sort(df)
但是当我尝试sort()
在这个 DateFrame 上使用该函数时,我得到了LoadError: MethodError: no method matching isless(::String, ::Dates.Date)
我认为这很奇怪,因为我在同一个 Excel 文件中有另一个选项卡,其中我有价格/天,并且可以正常排序。我看到的唯一区别是,在 Excel 文件中,价格/月选项卡的日期字段为日期,价格/日期选项卡的日期字段为任意。但在 DataFrame 中,两个选项卡都将 Date 字段标记为 Any。
我很难理解为什么价格/天选项卡可以使用sort()
而价格/月选项卡不能使用,而是它给了我LoadError
.