I am loading data from an Excel file that includes DateTime data. The DateTime string, when the time is 0:00 is parsed as a Date instead of a DateTime. An example of the data being loaded is:
Date a
2023-07-11 0:00 45.12
2023-07-11 0:01 45.14
2023-07-11 0:02 45.09
2023-07-11 0:03 44.69
2023-07-12 0:00 44.89
If this data is read from the Excel spreadsheet it gives the output:
julia> test = DataFrame(XLSX.readtable("test.xlsx", "Sheet1"))
5×2 DataFrame
Row │ Date a
│ Any Any
─────┼──────────────────────────────
1 │ 2023-07-11 45.1199
2 │ 2023-07-11T00:01:00 45.1426
3 │ 2023-07-11T00:02:00 45.0878
4 │ 2023-07-11T00:03:00 44.6917
5 │ 2023-07-12 44.8935
Another command will do better in terms of typing the non Date columns as follows:
julia> test = XLSX.openxlsx("test.xlsx") do xf
DataFrame(XLSX.gettable(xf["Sheet1"]; infer_eltypes=true))
end
5×2 DataFrame
Row │ Date a
│ Any Float64
─────┼──────────────────────────────
1 │ 2023-07-11 45.1199
2 │ 2023-07-11T00:01:00 45.1426
3 │ 2023-07-11T00:02:00 45.0878
4 │ 2023-07-11T00:03:00 44.6917
5 │ 2023-07-12 44.8935
I am able to get the desired DateTime type for the first column using the command
julia> test.Date = DateTime.(test.Date)
5-element Vector{DateTime}:
2023-07-11T00:00:00
2023-07-11T00:01:00
2023-07-11T00:02:00
2023-07-11T00:03:00
2023-07-12T00:00:00
However I don’t think that I should need to do this. I think the default behaviour for parsing a DateTime string like “2023-07-11 0:00” should return a DateTime type rather than a Date type.
Is this a bug?