Module: RedAmber::DataFrameIndexable
- Included in:
- DataFrame
- Defined in:
- lib/red_amber/data_frame_indexable.rb
Overview
Mix-ins for the class DataFrame
Instance Method Summary collapse
-
#indices(start = 0) ⇒ Object
(also: #indexes)
Returns row index Vector.
-
#sort(*sort_keys) ⇒ RedAmber::DataFrame
Sort the contents of self.
-
#sort_indices(*sort_keys) ⇒ RedAmber::Vector
Return sorted indexes of self by a Vector.
Instance Method Details
#indices ⇒ Vector #indices(start) ⇒ Vector Also known as: indexes
Returns row index Vector.
39 40 41 42 43 44 45 |
# File 'lib/red_amber/data_frame_indexable.rb', line 39 def indices(start = 0) if start == 0 # rubocop:disable Style/NumericPredicate @indices ||= Vector.new(0...size) else Vector.new((start..).take(size)) end end |
#sort(*sort_keys) ⇒ RedAmber::DataFrame
Sort the contents of self.
135 136 137 138 139 |
# File 'lib/red_amber/data_frame_indexable.rb', line 135 def sort(*sort_keys) indices = @table.sort_indices(sort_keys.flatten) take(indices) end |
#sort_indices(*sort_keys) ⇒ RedAmber::Vector
Return sorted indexes of self by a Vector.
73 74 75 76 |
# File 'lib/red_amber/data_frame_indexable.rb', line 73 def sort_indices(*sort_keys) indices = @table.sort_indices(sort_keys.flatten) Vector.create(indices) end |