<commit_before>type Timematr{T} <: AbstractTimematr
    vals::DataFrame
    idx::Array{T, 1}

    function Timematr(vals::DataFrame, idx::Array{T, 1})
        chkIdx(idx)
        chkNum(vals)
        if(size(vals, 1) != length(idx))
            if (length(idx) == 0) | (size(vals, 1) == 0)
                return new(DataFrame([]), Array{T, 1}[])
            end
            error(length(idx), " idx entries, but ", size(vals, 1), " rows of data")
        end
        return new(vals, idx)
    end
end

function Timematr{T}(vals::DataFrame, idx::Array{T, 1})
    return Timematr{T}(vals, idx)
end

    
#################
## Conversions ##
#################

## conversion upwards: always works
function convert(Timedata, tm::Timematr)
    Timedata(tm.vals, tm.idx)
end

## conversion upwards: always works
function convert(Timenum, tm::Timematr)
    Timenum(tm.vals, tm.idx)
end

#############################
## get numeric values only ##
#############################

## possible without NAs: extract values as Float64
function core(tm::AbstractTimematr)
    return convert(Array{Float64}, array(tm.vals))
end

#######################
## Timematr get mean ##
#######################

import Base.mean
function mean(tm::Timematr, dim::Int = 1)
    ## output: DataFrame, since date dimension is lost<commit_msg>alternative core(): Float64 not mandatory<commit_after>type Timematr{T} <: AbstractTimematr
    vals::DataFrame
    idx::Array{T, 1}

    function Timematr(vals::DataFrame, idx::Array{T, 1})
        chkIdx(idx)
        chkNum(vals)
        if(size(vals, 1) != length(idx))
            if (length(idx) == 0) | (size(vals, 1) == 0)
                return new(DataFrame([]), Array{T, 1}[])
            end
            error(length(idx), " idx entries, but ", size(vals, 1), " rows of data")
        end
        return new(vals, idx)
    end
end

function Timematr{T}(vals::DataFrame, idx::Array{T, 1})
    return Timematr{T}(vals, idx)
end

    
#################
## Conversions ##
#################

## conversion upwards: always works
function convert(Timedata, tm::Timematr)
    Timedata(tm.vals, tm.idx)
end

## conversion upwards: always works
function convert(Timenum, tm::Timematr)
    Timenum(tm.vals, tm.idx)
end

#############################
## get numeric values only ##
#############################

## possible without NAs: extract values as Float64
function core(tm::AbstractTimematr)
    return convert(Array{Float64}, array(tm.vals))
end
## alternative implementation not determining Float64
## function core(tm::AbstractTimematr)
##     return reshape([promote(array(tm.vals)...)...], size(tm))
## end

#######################
## Timematr get mean ##
#######################

import Base.mean
function mean(tm::Timematr, dim::Int = 1)
    ## output: DataFrame, since date dimension is lost
{'fraction_non_alphanumeric': 0.22612708555200567, 'fraction_numerical': 0.011359602413915513, 'mean_word_length': 3.8502581755593805, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '179976', 'n_tokens_mistral': 909, 'n_tokens_neox': 870, 'n_words': 220}