def cut partitions, opts={}
      close_at, labels = opts[:close_at] || :right, opts[:labels]
      partitions = partitions.to_a
      values = to_a.map { |val| cut_find_category partitions, val, close_at }
      cats = cut_categories(partitions, close_at)

      dv = Daru::Vector.new values,
        index: @index,
        type: :category,
        categories: cats

      # Rename categories if new labels provided
      if labels
        dv.rename_categories Hash[cats.zip(labels)]
      else
        dv
      end
    end
def cut partitions, opts={}
      close_at, labels = opts[:close_at] || :right, opts[:labels]
      partitions = partitions.to_a
      values = to_a.map { |val| cut_find_category partitions, val, close_at }
      cats = cut_categories(partitions, close_at)

      dv = Daru::Vector.new values,
        index: @index,
        type: :category,
        categories: cats

      # Rename categories if new labels provided
      if labels
        dv.rename_categories Hash[cats.zip(labels)]
      else
        dv
      end
    end
Partition a numeric variable into categories.
 @param [Array<Numeric>] partitions an array whose consecutive elements
   provide intervals for categories
 @param [Hash] opts options to cut the partition
 @option opts [:left, :right] :close_at specifies whether the interval closes at
   the right side of left side
 @option opts [Array] :labels names of the categories
 @return [Daru::Vector] numeric variable converted to categorical variable
 @example
   heights = Daru::Vector.new [30, 35, 32, 50, 42, 51]
   height_cat = heights.cut [30, 40, 50, 60], labels=['low', 'medium', 'high']
   # => #<Daru::Vector(6)>
   #       0    low
   #       1    low
   #       2    low
   #       3   high
   #       4 medium
   #       5   high