TimeData¶
Access metadata¶
-
idx(td::AbstractTimedata)¶ Get time index as array.
-
names(td::AbstractTimedata)¶ Get column names.
-
idxtype(td::AbstractTimedata)¶ Get type of
idx.
Access data as Array¶
-
get(td::AbstractTimedata, idx1::Int, idx2::Int)¶ Get single entry [idx1, idx2] of TimeData object.
-
get(td::AbstractTimedata) Get all entries of TimeData object as
Arraythrough comprehension.
-
core(td::AbstractTimedata)¶ Equal to
getexcept forTimematr.
-
core(tm::Timematr) Return data as
Array{Float64}.
-
getAs(tn::AbstractTimedata, typ::Type=Any, replaceNA=NA)¶ Get all entries as
Array. In order to avoidArray{Any, 2}as outcome, the entries can be promoted to a givenTypethrough argumenttyp. Missing values can be dealt with through a third argumentreplaceNA, which replaces occurringNAs. For example,Timenumtmcan be transformed toArray{Float64, 2}through:getAs(tm, Float64, NaN).
Access data as DataFrame¶
-
convert(::DataFrame, td::AbstractTimedata)¶ Convert
Timedataobject toDataFrameby prepending index column as column :idx.
Dealing with NAs¶
-
complete_cases(td::AbstractTimedata)¶ Return
Array{Bool}withtruefor rows withoutNAvalues.
-
narm(td::AbstractTimedata)¶ Get complete cases: return copy of td with all rows removed that were containing
NA.
-
rmDatesOnlyNAs(tn::AbstractTimedata)¶ Remove all dates that contain strictly missing values
NA. Required format, for example, for plotting with Gadfly.
Show entries¶
Accessing entries through getindex methods will always preserve a
rectangular table data structure: the output is an intersection of a
subset of indices with a subset of columns. In contrast,
showEntries methods allow to access data without rectangular
structure as stacked data. This way, for example, entry (1,2) and
entry (2,1) could be jointly accessed, without simultaneously
returning entries (1,1) and (2,2). The output of showEntries
always is of type Timedata, with columns variable and
value.
-
showEntries(td::AbstractTimedata, f::Function; sort="dates")¶ Show all entries where function f returns
true. By default, return values in row major order: for each date try all variables. Column major order can be achieved throughsort="variables".
-
showEntries(td::AbstractTimedata, singleInd::Array{Int}) Show entries given by linear indexing.
-
showEntries(td::AbstractTimedata, rowInds::Array{Int}, colInds::Array{Int}) Show entries given by subscript indexing.
-
showEntries(td::AbstractTimedata, td2::AbstractTimedata) Show entries by element-wise logical indexing.
Editing entries¶
-
setNA!(td::AbstractTimedata, rowIdx::Int, colIdx::Int) Set a given entry to
NA. Could require change of column type toDataArray. Throws error forTimematr.
-
setindex!(td::Timedata, value::Any, rowIdx::Int, colIdx::Int) Set entry given by subscript indexing to a given value.
-
setindex!(td::AbstractTimenum, value::Any, rowIdx::Int, colIdx::Int) Set entry given by subscript indexing to a given value.
-
impute!(td::AbstractTimedata, with="last") Replace
NAwith some value. Implemented options arelastto use the last available observation,nextto use the next available option,zeroto insert a value of 0 for eachNA.single lastonly uses the last observation if there is a singleNAin succession. For two or more successive values ofNAno imputation occurs. A singleNAin the last row will be treated as if observations would follow, so that it gets replaced. Consecutive occurrences ofNAat the beginning of the sample will be left untouched with optionslastandsingle last. Same holds for consecutive occurrences ofNAat the end of the sample for optionnext.
Basic functions¶
-
size(tn::AbstractTimedata)¶
-
size(tn::AbstractTimedata, ind::Int)
-
ndims(tn::AbstractTimedata)¶
Testing object properties¶
-
isequal(tn::AbstractTimedata, tn2::AbstractTimedata)¶ Test for equal indices, names, types and values.
NAis equal toNA. Output is a single value of typeBool.
-
isequalElw(tn::AbstractTimedata, tn2::AbstractTimedata)¶ Element-wise comparison with
isequal. ReturnsTimedatawith boolean values.
-
==(tn::AbstractTimedata, tn2::AbstractTimedata) Test for equal indices, names, types and values.
NAis not counted as equal toNA. Output is a single value of typeBool.
-
.==(tn::AbstractTimedata, tn2::AbstractTimedata) Element-wise test for equal values:
NAis not counted as equal toNA. ReturnsTimedatawith boolean values, or error if meta-data is not matching.
-
isapprox(tn::AbstractTimedata, tn2::AbstractTimedata)¶ Test for equal indices, names, types and approximately equal values. Alleviates unit tests for values of type
Float. Output is a single value of typeBool.
-
equMeta(td1::AbstractTimedata, td2::AbstractTimedata)¶ Test for equal meta-data: type, column names and indices. Output is a single value of type
Bool.
-
equColMeta(td1::AbstractTimedata, td2::AbstractTimedata)¶ Test for equal meta-data of columns (dates are left unconsidered): type and column names. Output is a single value of type
Bool.
-
isnaElw(td::AbstractTimedata)¶ Element-wise testing for
NA. Returns boolean values as Timedata object.
Date formatting functions¶
-
datesAsStrings(dats::Array{Date, 1})¶ Convert vector of dates into
Array{ASCIIString, n}.
-
datesAsStrings(tm::AbstractTimedata) Take
TimeDataobject and convert its vector of dates intoArray(ASCIIString, n).
-
datesAsNumbers(dats::Array{Date, 1})¶ Convert vector of dates into
Array{Float64, n}.
-
datesAsNumbers(tm::AbstractTimedata) Take
TimeDataobject and convert its vector of dates into numbers:Array{Float64, n}forDateandDateTimeentries.
Type preserving functions¶
-
hcat(inst::AbstractTimedata, inst2::AbstractTimedata)¶ Horizontal concatenation of TimeData objects. Requires objects to be of equal type with completely equal time indices. Result will be of same type as input arguments.
-
hcat(inst::AbstractTimedata...) Variable argument extension of
hcat.
-
vcat(inst::AbstractTimedata, inst2::AbstractTimedata)¶ Vertical concatenation of TimeData objects. Requires objects to be of equal type with equal column names and equal time index types. Result will be of same type as input arguments.
-
vcat(inst::AbstractTimedata...) Variable argument extension of
vcat.
-
flipud(inst::AbstractTimedata)¶ Flip
TimeDataobject upside down.
Conversion functions¶
-
asArrayOfEqualDimensions(arr::Array, td::AbstractTimedata)¶ Extend row or column vector to two-dimensional array through copying values.
-
asTd(arr::Array, td::Timedata)¶ Extend row or column vector to size of
Timedataobject similar torepmatand return it asTimedataobject with equal index and names.
-
asTn(arr::Array, td::Timenum)¶ Extend row or column vector to size of
Timenumobject similar torepmatand return it asTimenumobject with equal index and names.
-
asTm(arr::Array, td::Timematr)¶ Extend row or column vector to size of
Timematrobject similar torepmatand return it asTimematrobject with equal index and names.
-
convert(::Type{AbstractTimedata}, ta::TimeArray) Convert
TimeArraytoTimeDataobject.
DataFrame extensions¶
-
composeDataFrame(vals, nams)¶ Compose DataFrame from Array and column names.
-
round(df::DataFrame, nDgts::Int)¶ Return DataFrame with rounded values. DataFrame entries must be numeric.
-
round(df::DataFrame) Return DataFrame with values rounded to two significant digits. DataFrame entries must be numeric.
-
@roundDf(expr::Expr) Display rounded DataFrame. Works with non numeric values also.
Display functions¶
-
display(tn::AbstractTimedata)¶ Timedata display function in standard REPL.
-
writemime(io::IO, ::MIME"text/html", td::AbstractTimedata)¶ Timedata display function in ijulia.
-
writemime(io::IO, ::MIME"text/html", tm::AbstractTimematr) Timematr display function in ijulia. Values are rounded due to parsimony.
-
@table(title::String, expr::Union(Expr, Symbol)) Display expression or symbol in HTML with blue title header.
-
str(tn::AbstractTimedata)¶ More detailled display function similar to R syntax.
Statistics functions¶
-
mean(tm::AbstractTimematr, dim::Int = 1)¶ Return mean column values as DataFrame.
-
rowmeans(tm::AbstractTimematr)¶ Return mean row values as Timematr.
-
prod(tm::AbstractTimematr, dim::Int = 1)¶ Return product of column values as DataFrame.
-
rowprods(tm::AbstractTimematr)¶ Return product of row values as Timematr.
-
sum(tm::AbstractTimematr, dim::Int = 1)¶ Return sum of columns as DataFrame.
-
rowsums(tm::AbstractTimematr)¶ Return sum of rows as Timematr.
-
cov(tm::AbstractTimematr)¶ Return covariance matrix as DataFrame.
-
cor(tm::AbstractTimematr)¶ Return correlation matrix as DataFrame.
-
std(tm::AbstractTimematr)¶ Return empirical standard deviation for each column as DataFrame.
-
std(tm::AbstractTimematr, dim::Integer) Return empirical standard deviation for each column as DataFrame.
-
minimum(tm::AbstractTimematr)¶ Return minimum value as single value.
-
minimum(tm::AbstractTimematr, dim::Integer) Return minimum values of each column as DataFrame.
-
cumsum(tm::AbstractTimematr, dim::Integer)¶ Calculate cumulative sums column-wise and return result as Timematr.
-
cumprod(tm::AbstractTimematr, dim::Integer)¶ Calculate cumulative products column-wise and return result as Timematr.
-
rowstds(tm::AbstractTimematr)¶ Return empirical standard deviation for each row as Timematr.
-
geomMean(x::AbstractTimematr; percent = true)¶ Calculate geometric mean for AbstractTimedata.
-
geomMean(x; percent = true) Calculate geometric mean for Array.
-
movAvg(tm::AbstractTimematr, nPeriods::Integer)¶ Calculate moving average.
I/O¶
-
readTimedata(filename::String)¶ Load csv and parse date column as
idx.
-
writeTimedata(filename::String, td::AbstractTimedata)¶ Write TimeData object to csv file.
Join functions¶
For the case of monotonically increasing index values, join operations can be speeded up. The following join implementations exist. All return a Timedata object.
-
joinSortedIdx_inner(td1::AbstractTimedata, td2::AbstractTimedata)¶ Inner join of object indices.
-
joinSortedIdx_left(td1::AbstractTimedata, td2::AbstractTimedata)¶ Left join of object indices.
-
joinSortedIdx_right(td1::AbstractTimedata, td2::AbstractTimedata)¶ Right join of object indices.
-
joinSortedIdx_outer(td1::AbstractTimedata, td2::AbstractTimedata)¶ Outer join of object indices.