Method: Daru::DataFrame#set_row_at
- Defined in:
- lib/daru/dataframe.rb
#set_row_at(positions, vector) ⇒ Object
Set rows by positions
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 |
# File 'lib/daru/dataframe.rb', line 329 def set_row_at positions, vector validate_positions(*positions, nrows) vector = if vector.is_a? Daru::Vector vector.reindex @vectors else Daru::Vector.new vector end raise SizeError, 'Vector length should match row length' if vector.size != @vectors.size @data.each_with_index do |vec, pos| vec.set_at(positions, vector.at(pos)) end @index = @data[0].index set_size end |