lib/eps/data_frame.rb in eps-0.3.0 vs lib/eps/data_frame.rb in eps-0.3.1

- old
+ new

@@ -1,9 +1,9 @@ module Eps class DataFrame attr_reader :columns - attr_accessor :label + attr_accessor :label, :weight def initialize(data = []) @columns = {} if data.is_a?(Eps::DataFrame) @@ -76,10 +76,14 @@ if rows.is_a?(Range) if rows.end.nil? rows = Range.new(rows.begin, size - 1) elsif rows.end < 0 rows = Range.new(rows.begin, size + rows.end, rows.exclude_end?) + else + finish = rows.end + finish -= 1 if rows.exclude_end? + rows = Range.new(rows.begin, size - 1) if finish >= size - 1 end end if cols if cols.is_a?(Range) @@ -113,10 +117,11 @@ raise "Undefined column: #{c}" unless columns.include?(c) df.columns[c] = columns[c].values_at(*rows) end df.label = label.values_at(*rows) if label + df.weight = weight.values_at(*rows) if weight singular ? df.columns[cols[0]] : df end def ==(other) @@ -127,9 +132,10 @@ df = Eps::DataFrame.new columns.each do |k, v| df.columns[k] = v end df.label = label + df.weight = weight df end private