Sha256: 99b25e8bb2c867d14df5df31d8fb45322dedd5e8cacd4eba2fcaef9209a45574
Contents?: true
Size: 958 Bytes
Versions: 1
Compression:
Stored size: 958 Bytes
Contents
# frozen_string_literal: true module RedAmber # mix-ins for the class DataFrame module DataFrameIndexable # Common method def map_indices(*indices) return self if indices.empty? indices = indices[0].data if indices[0].is_a?(Vector) new_dataframe_by(indices) end # @param sort_keys [Arrow::SortKey] # :key, "key" or "+key" denotes ascending, # "-key" denotes descending order # @return [RedAmber::Vector] Sorted indices in Vector def sort_indices(*sort_keys) indices = @table.sort_indices(sort_keys.flatten) Vector.create(indices) end # @return [RedAmber::DataFrame] Sorted DataFrame def sort(*sort_keys) indices = @table.sort_indices(sort_keys.flatten) new_dataframe_by(indices) end private def new_dataframe_by(index_array) t = Arrow::Function.find(:take).execute([@table, index_array]).value DataFrame.create(t) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
red_amber-0.3.0 | lib/red_amber/data_frame_indexable.rb |