lib/eps/data_frame.rb in eps-0.3.9 vs lib/eps/data_frame.rb in eps-0.4.0
- old
+ new
@@ -83,10 +83,12 @@
else
finish = rows.end
finish -= 1 if rows.exclude_end?
rows = Range.new(rows.begin, size - 1) if finish >= size - 1
end
+ elsif rows.is_a?(Integer)
+ rows = [rows]
end
if cols
if cols.is_a?(Range)
c = columns.keys
@@ -116,13 +118,14 @@
df = Eps::DataFrame.new
cols.each do |c|
raise "Undefined column: #{c}" unless columns.include?(c)
- df.columns[c] = columns[c].values_at(*rows)
+ col = columns[c]
+ df.columns[c] = rows.map { |i| col[i] }
end
- df.label = label.values_at(*rows) if label
- df.weight = weight.values_at(*rows) if weight
+ df.label = rows.map { |i| label[i] } if label
+ df.weight = rows.map { |i| weight[i] } if weight
singular ? df.columns[cols[0]] : df
end
def ==(other)