SciRuby / daru

Data Analysis in RUby
BSD 2-Clause "Simplified" License
1.03k stars 139 forks source link

Suggested update to `DataFrame#to_matrix` #547

Open cmpprg opened 1 year ago

cmpprg commented 1 year ago

Hey ya'll. Trying to create a matrix of all my data including categorical. Why does Daru::DataFrame#to_matrix only include numerical data?

could we potentially create an opt out for this functionality? Current:

    def to_matrix
      Matrix.columns each_vector.select(&:numeric?).map(&:to_a)
    end

Suggestion(untested):

    def to_matrix(only_numeric: true)
      if only_numeric
        Matrix.columns each_vector.select(&:numeric?).map(&:to_a)
      else
        Matrix.columns each_vector.map(&:to_a)
    end
cmpprg commented 1 year ago

I can put in a PR if you want? Just wanted get feedback and see if I am missing something first.