customize how CalendarTime prints
milktrader opened this issue · 3 comments
I have gotten the CalendarTime
type into a DataFrame
here,
julia> head(GLD, 3)
3x5 DataFrame:
Date Open High Low Close
[1,] Nov 18, 2004 12:00:00 AM EST 44.43 44.49 44.07 44.38
[2,] Nov 19, 2004 12:00:00 AM EST 44.49 44.92 44.47 44.78
[3,] Nov 22, 2004 12:00:00 AM EST 44.75 44.97 44.74 44.95
julia> typeof(GLD[:,1])
DataVec{CalendarTime}
julia> GLD[nrow(GLD),1] - GLD[1,1]
2948 days
But it would be nice to have a less verbose print or show of CalendarTime
, so it looks like this contrived example:
julia> head(GLD,3)
3x5 DataFrame:
Date Open High Low Close
[1,] 2004-11-18 44.43 44.49 44.07 44.38
[2,] 2004-11-19 44.49 44.92 44.47 44.78
[3,] 2004-11-22 44.75 44.97 44.74 44.95
Hmm, i'm not sure what the best approach here is. Do you want to change the global default format? Or just for this particular DataFrame?
Changing the global default might be asking too much, since my preferred format may not be right for things other than a time series.
Is the formatting handled at the parse
function level or does it go lower-level? I'll pour over the code to see if I can figure this out. But I'd hope it would be as simple as writing a parse_timeseries
function that applied different formatting.
Or maybe it's in the show
method? Not sure.
okay, it's in show
. I'll checkout a branch and see if I can hack this to do what I'd like ..
Alright, the following is not contrived:
julia> head(GLD,3)
3x7 DataFrame:
Date Open High Low Close Volume Adj Close
[1,] 2004-11-18 44.43 44.49 44.07 44.38 5991500 44.38
[2,] 2004-11-19 44.49 44.92 44.47 44.78 11655300 44.78
[3,] 2004-11-22 44.75 44.97 44.74 44.95 11996000 44.95
julia> GLD[nrow(GLD),1] - GLD[1,1]
2948 days
The hack involves the show
method around line 189. I just commented out:
#s = ICU.format(_get_format(t.tz), t.millis)
And replaced it with:
s = format("yyyy-MM-dd", t)
I have this in my timeseries
branch and it works for me. Not sure how this fits in with the overall goals of the package.
Since this is a working solution, I'll close the issue.
Regards.